Skip to content

Breaking changes and bug fixes

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 01 Dec 04:18
· 1 commit to 3.x since this release

This release contains a few breaking changes along with a handful of new improvements and bug fixes.

Breaking changes

Infer type

The infer type of schema now marks optional fields as optional within the TypeScript types. This ensures the property can be missing altogether from the data object/inferred types vs being marked as undefined explicitly. For example:

// Schema
vine.object({
    username: vine.string(),
    age: vine.number().optional(),
})

// Old output
{
    age: number | undefined;
    username: string;
}

// New output
{
    age?: number | undefined;
    username: string;
}

SUBTYPE symbol

Custom types extending the VineJS BaseLiteralType now must define the symbols.SUBTYPE property on the schema. This property can be used by schema transformers to get a more accurate type for the schema node. Here's how the StringSchema defines the SUBTYPE property.

For example:

import { symbols, BaseLiteralType } from '@vinejs/vine'

class MySchemaType extends BaseLiteralType<Input, Output, CamelCaseOutput> {
   [symbols.SUBTYPE] = 'multipartFile'
}

Bug Fixes

  • add tests to ensure field names with special chars are allowed (67f6c52), closes #50 #63 #82
  • do not use Error.captureStackTrace when not available (715e761), closes #49
  • infer types (#79) (54f5237)

Features

  • add subtype property to schema output (818fbf0), closes #64
  • add support for conditional validation in arrays, object, records and tuples (890228e), closes #71
  • add support for parsing iso8601 dates (fe61951), closes #65
  • add support for ULID validation (#58) (02d3a28)

Pull Requests

New Contributors

Full Changelog: v2.1.0...v3.0.0