NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm · #2666 most downloaded on npm
The modular and type safe schema library for validating structural data
Last release 25 days ago
09 Sep 2026
Release timing varies
gaps range from 8 days to 7 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
3 years old
98 releases · first in 2023
One column per quarter.
Remove deprecated properties of safeParse and safeParseAsync method
Many thanks to @Saeris, @ariskemper, @mxdvl, @romeerez and @niccholaspage for contributing to this release.
Default and DefaultAsync type and refactor codebaseFallback and FallbackAsync type and refactor codebaseisOfType type guard util to check the type of an objectgetDefaults and getDefaultsAsync method (pull request #259)getFallbacks and getFallbacksAsync method (pull request #259)type to interface (pull request #259, #451)safeParse and safeParseAsync methodNestedPath type of flatten for async schemas (issue #456)DefaultValue type for transformed valuesMany thanks to @Mini-ghost, @ivands and @Demivan for contributing to this release.
Many thanks to @Mini-ghost, @ivands and @Demivan for contributing to this release.
every and some pipeline validation actioninput of schema to getter function of recursive and recursiveAsync schema (pull request #441)transform and transformAsync method to only run transformations if there are no issues (issue #436)recursive and recursiveAsync schema to lazy and lazyAsync (issue #440)i18n util when using setSchemaMessageMany thanks to @compulim for contributing to this release.
Many thanks to @compulim for contributing to this release.
union and unionAsync schema for transformed inputs (issue #420)Many thanks to @LorisSigrist, @samuelstroschein, @gmaxlev, @thundermiracle, @ivanhofer, @CanRau, @zkulbeda, @lucaschultz, @paoloricciuti, @hyunbinseo,
Many thanks to @LorisSigrist, @samuelstroschein, @gmaxlev, @thundermiracle, @ivanhofer, @CanRau, @zkulbeda, @lucaschultz, @paoloricciuti, @hyunbinseo, and @bertez for contributing to this release.
Note: The library has been revised and refactored. Therefore, not every change is listed in detail.
number and bigint to PicklistOptions type (issue #378)forwardAsync method (issue #412)Many thanks to @Omochice for contributing to this release.
Many thanks to @Omochice for contributing to this release.
Many thanks to @pschiffmann for contributing to this release.
Many thanks to @pschiffmann for contributing to this release.
NonNullable, NonNullish and NonOptional typeNonNullableInput, NonNullableOutput, NonNullishInput, NonNullishOutput, NonOptionalInput and NonOptionalOutput typeomit, omitAsync, pick and pickAsync schema to also allow read-only object keys (issue #380)pipe argument at intersect and intersectAsync schemaThe changes in union, unionAsync, variant and variantAsync are breaking changes and may result in different behavior when returning issues. Please cre…
Many thanks to @WtfJoke, @dboune, @alexabw and @aypotu for contributing to this release.
enum_ and enumAsync schema by caching valuesunion, unionAsync, variant and variantAsync schema to improve developer experiencegetDefaults, getDefaultsAsync, getFallbacks and getFallbacksAsync schema for falsy but not undefined values (issue #356)pipe argument at union, unionAsync, variant and variantAsync schemaunion, unionAsync, variant and variantAsync schema (issue #364)startsWith validation action (pull request #375)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(''),
]);
Many thanks to @ariskemper, @ewautr, @cuberoot @lo1tuma and @richardvanbergen for contributing to this release.
Many thanks to @ariskemper, @ewautr, @cuberoot @lo1tuma and @richardvanbergen for contributing to this release.
creditCard, decimal, hash, hexadecimal, hexColor and octal pipeline validation action (pull request #292, #304, #307, #308, #309)pipe parameter to intersect, intersectAsync, union, unionAsync, variant and variantAsync schema (discussion #297)variant and variantAsync schema (issue #310)variant and variantAsync schema is missing (issue #235, #303)PicklistOptions type and generics of picklist and picklistAsync schemaMany thanks to @NotWorkingCode for contributing to this release.
Many thanks to @NotWorkingCode for contributing to this release.
object and objectAsync entries with default value (issue #286)nullable, nullableAsync, nullish, nullishAsync, optional and optionalAsync schema with default value (issue #286)Many thanks to @genki and @NotWorkingCode for contributing to this release.
Many thanks to @genki and @NotWorkingCode for contributing to this release.
special schema as key of record schema (issue #291)special and specialAsync schema as key of recordAsync schema (issue #291)Many thanks to @ariskemper, @ivands and @emilgpa for contributing to this release.
Many thanks to @ariskemper, @ivands and @emilgpa for contributing to this release.
bic validation function (pull request #284)mac, mac48 and mac64 validation function (pull request #270)PicklistOptions, UnionOptions and UnionOptionsAsync type from tuple to array (issue #279)IntersectOptions, IntersectOptionsAsync, UnionOptions and UnionOptionsAsync type to support readonly values (issue #279)ObjectInput and ObjectOutput type (issue #242)Many thanks to @ecyrbe, @Demivan, @GriefMoDz, @demarchenac, @TFX0019, @AbePlays, @irg1008, @skotenko, @dukeofsoftware, @xxxhussein, @JortsEnjoyer0, @K
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.
notValue validation (pull request #261).typed to schema validation result and execute pipeline of complex schemas if output is typed (issue #76, #145)forward method that forwards issues of pipelines to nested fields (issue #76, #145)skipPipe option to is type guard method (pull request #166)safeParse and safeParseAsync methodRecordInput and RecordOuput type when using unionAsync as keynullable, nullableAsync, nullish, nullishAsync, optional and optionalAsync when using a default value (issue #271)Many thanks to @Saeris, @lo1tuma, @david-plugge, @ciscoheat, @kazizi55 and @BastiDood for contributing to this release.
Many thanks to @Saeris, @lo1tuma, @david-plugge, @ciscoheat, @kazizi55 and @BastiDood for contributing to this release.
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.
Many thanks to @lo1tuma for contributing to this release.
Many thanks to @lo1tuma for contributing to this release.
never from type signatur of strict objects and tuples (issue #234)Deprecate passthrough, strict and strip method in favor of object schema with rest argument
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.
getRestAndDefaultArgs utility functionrest argument to object and objectAsync schemavariant and variantAsync schema (issue #90, #216)getFallback property to schema in fallback method (pull request #177)PartialObjectEntries and PartialObjectEntriesAsync type (issue #217)getDefaultAsync, getDefaults and getDefaultsAsync, getFallback, getFallbackAsync, getFallbacks, getFallbacksAsync method (issue #155)transform and transformAsyncdate and dateAsync for invalid dates (pull request #214)optional, optionalAsync, nullable, nullableAsync, nullish and nullishAsync schemaObjectSchema and ObjectSchemaAsync typetuple and tupleAsync to be less strictaction argument in coerce and coerceAsync to unknownbrand, getDefault, transform and transformAsync methodarray, arrayAsync, intersection, intersectionAsync, map, mapAsync, object, objectAsync, union, unionAsync, record, recordAsync, set, setAsync, tuple and tupleAsync schemaschema property of every schema type to typeintersection and intersectionAsync schema to intersect and intersectAsyncenumType and enumTypeAsync schema to picklist and picklistAsyncnativeEnum and nativeEnumAsync schema to enum_ and enumAsyncnullType and nullTypeAsync schema to null_ and nullAsyncundefinedType and undefinedTypeAsync schema to undefined_ and undefinedAsyncvoidType and voidTypeAsync schema to void_ and voidAsyncdefault property of optional, optionalAsync, nullable, nullableAsync, nullish and nullishAsync schema to getDefaultObjectShape and ObjectShapeAsync types to ObjectEntries and ObjectEntriesAsyncTupleShape and TupleShapeAsync types to TupleItems and TupleItemsAsyncpassthrough, strict and strip method in favor of object schema with rest argumentUnfortunately, 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.
Deprecate equal validation function in favor of value (issue #192)
Many thanks to @lo1tuma, @Saeris, @sillvva, @kazizi55, @FleetAdmiralJakob, @kurtextrem, @xinha-sh and @husseyexplores for contributing to this release.
notBytes, notLength, notSize and notValue validation function (pull request #194)record and recordAsync schema (issue #201)transform and transformAsync (issue #197)email validation to improve performance and security (pull request #180)object and objectAsync schema to exclude non-existing keys (issue #199)brand, transform and unwrap method (issue #195)equal validation function in favor of value (issue #192)Many thanks to @alonidiom, @davidmyersdev, @Karakatiza666, @abd2561024 and @brandonpittman for contributing to this release.
Many thanks to @alonidiom, @davidmyersdev, @Karakatiza666, @abd2561024 and @brandonpittman for contributing to this release.
intersection and intersectionAsync schema (pull request #117)RecordInput and RecordOutput type (pull request #184)RecordSchema and RecordSchemaAsync typeflatten function and improve typesMany thanks to @syhol and @adoublef for contributing to this release.
Many thanks to @syhol and @adoublef for contributing to this release.
Many thanks to @zkulbeda, @vicimpa, @jonlambert and @gmaxlev for contributing to this release.
Many thanks to @zkulbeda, @vicimpa, @jonlambert and @gmaxlev for contributing to this release.
skipPipe option to skip execution of pipelines (pull request #164)Many thanks to @jmcdo29, @divndev and @demarchenac for contributing to this release.
Many thanks to @jmcdo29, @divndev and @demarchenac for contributing to this release.
ulid validation (pull request #151)getIssues, getOutput and getPipeIssues util and refactor codenumber and numberAsync schema (issue #157)PipeResult type to allow multiple issues (issue #161)getIssues util to getSchemaIssuesFor individual validation within a pipeline, it is now possible to return multiple issues. In addition, we provide two helper functions with getOutput and getPipeIssues to make your code more readable.
import { getOutput, getPipeIssues, string } from 'valibot';
// Change this
const StringSchema = string([
(input) => {
if (input.length > 10) {
return {
issue: {
validation: 'custom',
message: 'Invalid length',
input,
},
};
}
return { output: input };
},
]);
// To that
const StringSchema = string([
(input) =>
input.length > 10
? getPipeIssues('custom', 'Invalid length', input)
: getOutput(input),
]);
Deprecate withDefault method in favor of optional schema
Many thanks to @demarchenac, @Demivan, @david-plugge, @abd2561024 and @ooga for contributing to this release.
record and recordAsync schema (issue #134)optional, optionalAsync, nullable, nullableAsync, nullish and nullishAsync schema (issue #96, #118)getDefault method to get default value of schema (issue #105)withDefault method in favor of optional schemaMany thanks to @samualtnorman, @dmorosinotto, @FabienDehopre and @Yovach for contributing to this release.
Many thanks to @samualtnorman, @dmorosinotto, @FabienDehopre and @Yovach for contributing to this release.
cuid2 validation (pull request #130)passthrough, passthroughAsync, strip and stripAsync methodInstanceSchemaAsync overload to transformAsync method (pull request #138)strict and strictAsync method for optional keys (issue #131)Change object type check in object and record schema
object and record schemaThis version brings extreme performance improvements. However, this also required a few breaking changes. Below is an explanation of how these can be…
Many thanks to @naruaway, @zkulbeda, @kurtextrem, @BastiDood, @ssalbdivad, @jussisaurio, @FlorianDevPhynix, @milankinen, @fvckDesa and @Demivan for contributing to this release.
fallback and fallbackAsync method (pull request #103)excludes validation as negation of includesliteral schema (pull request #102)withDefault methodflatten function so that issues are also accepted as argumentsafeParse and safeParseAsync method.parse to ._parse and .types to ._types to mark it as internalThis version brings extreme performance improvements. However, this also required a few breaking changes. Below is an explanation of how these can be solved quite easily.
.parseIf you have been using the internal .parse API of a schema for validation directly, you must now switch to the parse method.
// Change this
YourSchema.parse(input);
// To that
parse(YourSchema, input);
safeParseFor safeParse we have depredated .data and .error. Use .output and .issues instead.
const result = safeParse(YourSchema, input);
if (result.success) {
// Change this
const output = result.data;
// To that
const output = result.output;
} else {
// Change this
const issues = result.error.issues;
// To that
const issues = result.issues;
}
If you still want to work with a ValiError, you can easily create a ValiError yourself.
const error = new ValiError(result.issues)
If you previously threw a ValiError on your own, for example in the pipeline of a schema, you must now return an object with an issue or output.
// Change this
const StringSchema = string([
(input, info) => {
if (input.length > 10) {
throw new ValiError([
{
validation: 'custom',
origin: 'value',
message: 'Invalid length',
input,
...info,
},
]);
}
return input;
},
]);
// To that
const StringSchema = string([
(input) => {
if (input.length > 10) {
return {
issue: {
validation: 'custom',
message: 'Invalid length',
input,
},
};
}
return { output: input };
},
]);
Unfortunately we could not find a solution for tRPC yet. Currently you can either explicitly set your Valibot version to v0.12.0, call parse on your own or use TypeSchema as a layer in between.
Option 1:
npm install valibot@0.12.0 # npm
yarn add valibot@0.12.0 # yarn
pnpm add valibot@0.12.0 # pnpm
bun add valibot@0.12.0 # bun
Option 2:
import { parse } from 'valibot';
.input((input) => parse(YourSchema, input))
Option 3:
import { wrap } from '@decs/typeschema';
.input(wrap(YourSchema))
Many thanks to @naruaway, @MineLPPhynix, @mrsekut and @zkulbeda for contributing to this release.
Many thanks to @naruaway, @MineLPPhynix, @mrsekut and @zkulbeda for contributing to this release.
mimeType validation to BlobuseDefault method to withDefault (issue #80)brand method to support branded types (pull request #85)Many thanks to @jdgamble555 and @BastiDood for contributing to this release.
Many thanks to @jdgamble555 and @BastiDood for contributing to this release.
enumType and enumTypeAsync schema (issue #70)Fix prototype pollution vulnerability of record and recordAsync (pull request #67)
Many thanks to @NiclasHaderer and @gmaxlev for contributing to this release.
record and recordAsync (pull request #67)finite, safeInteger and multipleOf validation (pull request #64, #65, #66)Many thanks to @gmaxlev for contributing to this release.
Many thanks to @gmaxlev for contributing to this release.
integer validation (pull request #62)Many thanks to @Danielwinkelmann and @sillvva for contributing to this release.
Many thanks to @Danielwinkelmann and @sillvva for contributing to this release.
imei validation and isLuhnAlgo util (pull request #37)isoDateTime, isoTime, isoTimeSecond and isoTimestamp validation (pull request #42)Many thanks to @Thanaen, @hungify and @yamiteru for contributing to this release.
Many thanks to @Thanaen, @hungify and @yamiteru for contributing to this release.
object and record types (issue #9, #10, #34)strict and strictAsync method to detect unknown object keysMany thanks to @JoakimDeak, @jasikpark, @luxferoo, @logaretm and @Yovach for contributing to this release.
Many thanks to @JoakimDeak, @jasikpark, @luxferoo, @logaretm and @Yovach for contributing to this release.
is method which can be used as a type guard (pull request #13)abortPipeEarly option to abort pipe on first error (issues #18)abortEarly option to abort on first errorAdd toMinValue and toMaxValue transformation
toMinValue and toMaxValue transformationMany thanks to @lino-levan, @emilbonnek and @kiliman for contributing to this release.
Many thanks to @lino-levan, @emilbonnek and @kiliman for contributing to this release.
comparable import when using DenominRange and maxRange to minValue and maxValue (issue #20)value validation functionMany thanks to @lino-levan for contributing to this release.
Many thanks to @lino-levan for contributing to this release.
instance and instanceAsync schemaMany thanks to @genki, @tigawanna, @userquin, @intrnl and @andrewbranch for contributing to this release.
Many thanks to @genki, @tigawanna, @userquin, @intrnl and @andrewbranch for contributing to this release.
bytes, minBytes and maxBytes validation (pull request #1)Many thanks to @tigawanna, @userquin and @intrnl for contributing to this release.
Many thanks to @tigawanna, @userquin and @intrnl for contributing to this release.
- Add blob and blobAsync schema
blob and blobAsync schemaMany thanks to @mhevery, @ryansolid and @colinhacks for contributing to this release.
Many thanks to @mhevery, @ryansolid and @colinhacks for contributing to this release.
Your coding agent can read these notes before it upgrades. Set up the MCP server →