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
- Export VineNativeEnum class by @simoneNEMO in #60
- Add support for ULID validation by @simoneNEMO in #58
- docs: fix JSDoc comment on regex function by @Elliot67 in #77
- fix: infer types by @adamcikado in #79
New Contributors
- @simoneNEMO made their first contribution in #60
- @Elliot67 made their first contribution in #77
Full Changelog: v2.1.0...v3.0.0