Releases: fabian-hiller/valibot
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.
v0.19.0
Many thanks to @lo1tuma, @Saeris, @sillvva, @kazizi55, @FleetAdmiralJakob, @kurtextrem, @xinha-sh and @husseyexplores for contributing to this release.
- Add
notBytes
,notLength
,notSize
andnotValue
validation function (pull request #194) - Add support for unions as key of
record
andrecordAsync
schema (issue #201) - Add support for pipeline validation to
transform
andtransformAsync
(issue #197) - Change regex of
email
validation to improve performance and security (pull request #180) - Change
object
andobjectAsync
schema to exclude non-existing keys (issue #199) - Fix types at
brand
,transform
andunwrap
method (issue #195) - Deprecate
equal
validation function in favor ofvalue
(issue #192)
v0.18.0
Many thanks to @alonidiom, @davidmyersdev, @Karakatiza666, @abd2561024 and @brandonpittman for contributing to this release.