Releases: fabian-hiller/valibot
v0.27.0
Many thanks to @pschiffmann for contributing to this release.
- Remove
NonNullable
,NonNullish
andNonOptional
type - Add
NonNullableInput
,NonNullableOutput
,NonNullishInput
,NonNullishOutput
,NonOptionalInput
andNonOptionalOutput
type - Improve type signature of
omit
,omitAsync
,pick
andpickAsync
schema to also allow read-only object keys (issue #380) - Fix type of
pipe
argument atintersect
andintersectAsync
schema
v0.26.0
Many thanks to @WtfJoke, @dboune, @alexabw and @aypotu for contributing to this release.
- Improve performance of
enum_
andenumAsync
schema 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
,variant
andvariantAsync
schema to improve developer experience - Fix bug in
getDefaults
,getDefaultsAsync
,getFallbacks
andgetFallbacksAsync
schema for falsy but notundefined
values (issue #356) - Fix type of
pipe
argument atunion
,unionAsync
,variant
andvariantAsync
schema - Fix bug that broke pipeline execution in
union
,unionAsync
,variant
andvariantAsync
schema (issue #364) - Fix typo in type name of
startsWith
validation 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
,hexColor
andoctal
pipeline validation action (pull request #292, #304, #307, #308, #309) - Add
pipe
parameter tointersect
,intersectAsync
,union
,unionAsync
,variant
andvariantAsync
schema (discussion #297) - Add support for multiple variant options with same discriminator key to
variant
andvariantAsync
schema (issue #310) - Add path to issues if discriminator key of
variant
andvariantAsync
schema is missing (issue #235, #303) - Change
PicklistOptions
type and generics ofpicklist
andpicklistAsync
schema
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
bic
validation function (pull request #284) - Add
mac
,mac48
andmac64
validation function (pull request #270) - Change
PicklistOptions
,UnionOptions
andUnionOptionsAsync
type from tuple to array (issue #279) - Change
IntersectOptions
,IntersectOptionsAsync
,UnionOptions
andUnionOptionsAsync
type to support readonly values (issue #279) - Fix optional keys of
ObjectInput
andObjectOutput
type (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
notValue
validation (pull request #261) - Add
.typed
to schema validation result and execute pipeline of complex schemas if output is typed (issue #76, #145) - Add
forward
method that forwards issues of pipelines to nested fields (issue #76, #145) - Add
skipPipe
option tois
type guard method (pull request #166) - Change return type of
safeParse
andsafeParseAsync
method - Rename and change util functions and refactor codebase
- Fix
RecordInput
andRecordOuput
type when usingunionAsync
as key - Fix output type for
nullable
,nullableAsync
,nullish
,nullishAsync
,optional
andoptionalAsync
when 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
getRestAndDefaultArgs
utility function - Add
rest
argument toobject
andobjectAsync
schema - Add
variant
andvariantAsync
schema (issue #90, #216) - Add
getFallback
property to schema infallback
method (pull request #177) - Add
PartialObjectEntries
andPartialObjectEntriesAsync
type (issue #217) - Add export for any validation regex (pull request #219)
- Add
getDefaultAsync
,getDefaults
andgetDefaultsAsync
,getFallback
,getFallbackAsync
,getFallbacks
,getFallbacksAsync
method (issue #155) - Add support for schema validation to
transform
andtransformAsync
- Fix type check in
date
anddateAsync
for invalid dates (pull request #214) - Improve security of regular expressions (pull request #202)
- Improve
optional
,optionalAsync
,nullable
,nullableAsync
,nullish
andnullishAsync
schema - Change
ObjectSchema
andObjectSchemaAsync
type - Change type check in
tuple
andtupleAsync
to be less strict - Change return type of
action
argument incoerce
andcoerceAsync
tounknown
- Change type of
brand
,getDefault
,transform
andtransformAsync
method - Change type of
array
,arrayAsync
,intersection
,intersectionAsync
,map
,mapAsync
,object
,objectAsync
,union
,unionAsync
,record
,recordAsync
,set
,setAsync
,tuple
andtupleAsync
schema - Rename
schema
property of every schema type totype
- Rename
intersection
andintersectionAsync
schema tointersect
andintersectAsync
- Rename
enumType
andenumTypeAsync
schema topicklist
andpicklistAsync
- Rename
nativeEnum
andnativeEnumAsync
schema toenum_
andenumAsync
- Rename
nullType
andnullTypeAsync
schema tonull_
andnullAsync
- Rename
undefinedType
andundefinedTypeAsync
schema toundefined_
andundefinedAsync
- Rename
voidType
andvoidTypeAsync
schema tovoid_
andvoidAsync
- Rename
default
property ofoptional
,optionalAsync
,nullable
,nullableAsync
,nullish
andnullishAsync
schema togetDefault
- Rename
ObjectShape
andObjectShapeAsync
types toObjectEntries
andObjectEntriesAsync
- Rename
TupleShape
andTupleShapeAsync
types toTupleItems
andTupleItemsAsync
- Deprecate
passthrough
,strict
andstrip
method in favor ofobject
schema withrest
argument
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.