Releases: open-circle/valibot
v0.27.0
Many thanks to @pschiffmann for contributing to this release.
- Remove
NonNullable,NonNullishandNonOptionaltype - Add
NonNullableInput,NonNullableOutput,NonNullishInput,NonNullishOutput,NonOptionalInputandNonOptionalOutputtype - Improve type signature of
omit,omitAsync,pickandpickAsyncschema to also allow read-only object keys (issue #380) - Fix type of
pipeargument atintersectandintersectAsyncschema
v0.26.0
Many thanks to @WtfJoke, @dboune, @alexabw and @aypotu for contributing to this release.
- Improve performance of
enum_andenumAsyncschema by caching values - Change ISO timestamp regex to support timestamps with lower and higher millisecond accuracy (pull request #353)
- Change issue handling of
union,unionAsync,variantandvariantAsyncschema to improve developer experience - Fix bug in
getDefaults,getDefaultsAsync,getFallbacksandgetFallbacksAsyncschema for falsy but notundefinedvalues (issue #356) - Fix type of
pipeargument atunion,unionAsync,variantandvariantAsyncschema - Fix bug that broke pipeline execution in
union,unionAsync,variantandvariantAsyncschema (issue #364) - Fix typo in type name of
startsWithvalidation action (pull request #375)
Migration guide
The changes in union, unionAsync, variant and variantAsync are breaking changes and may result in different behavior when returning issues. Please create an issue if you have questions about this.
import * as v from 'valibot';
// Change this
const UnionSchema = v.union(
[v.string([v.email()]), v.literal('')],
'Not a valid email'
);
// To that
const UnionSchema = v.union([
v.string([v.email('Not a valid email')]),
v.literal(''),
]);v0.25.0
Many thanks to @ariskemper, @ewautr, @cuberoot @lo1tuma and @richardvanbergen for contributing to this release.
- Add
creditCard,decimal,hash,hexadecimal,hexColorandoctalpipeline validation action (pull request #292, #304, #307, #308, #309) - Add
pipeparameter tointersect,intersectAsync,union,unionAsync,variantandvariantAsyncschema (discussion #297) - Add support for multiple variant options with same discriminator key to
variantandvariantAsyncschema (issue #310) - Add path to issues if discriminator key of
variantandvariantAsyncschema is missing (issue #235, #303) - Change
PicklistOptionstype and generics ofpicklistandpicklistAsyncschema
v0.24.1
Many thanks to @NotWorkingCode for contributing to this release.
v0.24.0
Many thanks to @genki and @NotWorkingCode for contributing to this release.
v0.23.0
Many thanks to @ariskemper, @ivands and @emilgpa for contributing to this release.
- Add
bicvalidation function (pull request #284) - Add
mac,mac48andmac64validation function (pull request #270) - Change
PicklistOptions,UnionOptionsandUnionOptionsAsynctype from tuple to array (issue #279) - Change
IntersectOptions,IntersectOptionsAsync,UnionOptionsandUnionOptionsAsynctype to support readonly values (issue #279) - Fix optional keys of
ObjectInputandObjectOutputtype (issue #242)
v0.22.0
Many thanks to @ecyrbe, @Demivan, @GriefMoDz, @demarchenac, @TFX0019, @AbePlays, @irg1008, @skotenko, @dukeofsoftware, @xxxhussein, @JortsEnjoyer0, @Karakatiza666, @micahjon, @lulucas, @xsjcTony, @ziyak97, @micha149, @anhzf and @jonlambert for contributing to this release.
- Add support for boolean to
notValuevalidation (pull request #261) - Add
.typedto schema validation result and execute pipeline of complex schemas if output is typed (issue #76, #145) - Add
forwardmethod that forwards issues of pipelines to nested fields (issue #76, #145) - Add
skipPipeoption toistype guard method (pull request #166) - Change return type of
safeParseandsafeParseAsyncmethod - Rename and change util functions and refactor codebase
- Fix
RecordInputandRecordOuputtype when usingunionAsyncas key - Fix output type for
nullable,nullableAsync,nullish,nullishAsync,optionalandoptionalAsyncwhen using a default value (issue #271)
v0.21.0
Many thanks to @Saeris, @lo1tuma, @david-plugge, @ciscoheat, @kazizi55 and @BastiDood for contributing to this release.
- Change structure of schemas, validations and transformations to make properties accessible (pull request #211)
- Fix errors in JSDoc comments and add JSDoc ESLint plugin (pull request #205)
- Fix missing file extension for Deno (pull request #249)
Migration guide
The internal structure of schema and pipeline functions has changed as a result of #211. These changes affect people who have created their own schema, validation, or transformation functions.
import { type BaseValidation, type ErrorMessage, getOutput, getPipeIssues } from 'valibot';
// Change this
export function minLength<TInput extends string | any[]>(
requirement: number,
error?: ErrorMessage
) {
return (input: TInput): PipeResult<TInput> =>
input.length < requirement
? getPipeIssues('min_length', error || 'Invalid length', input)
: getOutput(input);
}
// To that
export type MinLengthValidation<
TInput extends string | any[],
TRequirement extends number
> = BaseValidation<TInput> & {
type: 'min_length';
requirement: TRequirement;
};
export function minLength<
TInput extends string | any[],
TRequirement extends number
>(
requirement: TRequirement,
message: ErrorMessage = 'Invalid length'
): MinLengthValidation<TInput, TRequirement> {
return {
type: 'min_length',
async: false,
message,
requirement,
_parse(input) {
return input.length < this.requirement
? getPipeIssues(this.type, this.message, input, this.requirement)
: getOutput(input);
},
};
}If you have any questions or problems, please have a look at the source code or create an issue. I usually respond within 24 hours.
v0.20.1
v0.20.0
Many thanks to @lo1tuma, @Karakatiza666, @naveen-bharathi, @jsudelko, @danielo515, @iamriajul, @brandonpittman, @marek-hanzal, @kurtextrem, @BThomann, @hermanseder, @sillvva, @tjenkinson and many more peoples for contributing to this release.
- Add
getRestAndDefaultArgsutility function - Add
restargument toobjectandobjectAsyncschema - Add
variantandvariantAsyncschema (issue #90, #216) - Add
getFallbackproperty to schema infallbackmethod (pull request #177) - Add
PartialObjectEntriesandPartialObjectEntriesAsynctype (issue #217) - Add export for any validation regex (pull request #219)
- Add
getDefaultAsync,getDefaultsandgetDefaultsAsync,getFallback,getFallbackAsync,getFallbacks,getFallbacksAsyncmethod (issue #155) - Add support for schema validation to
transformandtransformAsync - Fix type check in
dateanddateAsyncfor invalid dates (pull request #214) - Improve security of regular expressions (pull request #202)
- Improve
optional,optionalAsync,nullable,nullableAsync,nullishandnullishAsyncschema - Change
ObjectSchemaandObjectSchemaAsynctype - Change type check in
tupleandtupleAsyncto be less strict - Change return type of
actionargument incoerceandcoerceAsynctounknown - Change type of
brand,getDefault,transformandtransformAsyncmethod - Change type of
array,arrayAsync,intersection,intersectionAsync,map,mapAsync,object,objectAsync,union,unionAsync,record,recordAsync,set,setAsync,tupleandtupleAsyncschema - Rename
schemaproperty of every schema type totype - Rename
intersectionandintersectionAsyncschema tointersectandintersectAsync - Rename
enumTypeandenumTypeAsyncschema topicklistandpicklistAsync - Rename
nativeEnumandnativeEnumAsyncschema toenum_andenumAsync - Rename
nullTypeandnullTypeAsyncschema tonull_andnullAsync - Rename
undefinedTypeandundefinedTypeAsyncschema toundefined_andundefinedAsync - Rename
voidTypeandvoidTypeAsyncschema tovoid_andvoidAsync - Rename
defaultproperty ofoptional,optionalAsync,nullable,nullableAsync,nullishandnullishAsyncschema togetDefault - Rename
ObjectShapeandObjectShapeAsynctypes toObjectEntriesandObjectEntriesAsync - Rename
TupleShapeandTupleShapeAsynctypes toTupleItemsandTupleItemsAsync - Deprecate
passthrough,strictandstripmethod in favor ofobjectschema withrestargument
Migration guide
Unfortunately, I haven't had time to write a migration guide yet. If you have any questions or problems, please have a look at the source code or create an issue. I usually respond within 24 hours.