The modular and type safe schema library for validating structural data 🤖
MIT License
Bot releases are hidden (Show)
Many thanks to @naveen-bharathi for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
intersect
schema (issue #601)Published by fabian-hiller 5 months ago
Many thanks to @AlexXanderGrib, @chertik77 and @chimame for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
Published by fabian-hiller 5 months ago
Many thanks to @chimame for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
variant
schema (pull request #600)Published by fabian-hiller 5 months ago
Many thanks to @jansedlon for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
Default
type for optional
, nullable
and nullish
schema (issue #593)Published by fabian-hiller 5 months ago
Many thanks to @jansedlon and @mutewinter for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
optional
, nullable
and nullish
schema (issue #593, #363)Published by fabian-hiller 5 months ago
Many thanks to @Demivan, @EltonLobo07, @xcfox, @mxdvl, @Afsoon, @IlyaSemenov, @Saeris, @devcaeg, @AndreyYolkin, @MrGeniusProgrammer, @znycheporuk, @macarie and many others for contributing to this release.
To migrate from an older version, please see the official migration guide: https://valibot.dev/guides/migrate-from-v0.30.0/
Published by fabian-hiller 8 months ago
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 valuesPublished by fabian-hiller 8 months ago
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 setSchemaMessage
Published by fabian-hiller 9 months ago
Many thanks to @compulim for contributing to this release.
union
and unionAsync
schema for transformed inputs (issue #420)Published by fabian-hiller 9 months ago
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)Published by fabian-hiller 9 months ago
Many thanks to @Omochice for contributing to this release.
Published by fabian-hiller 9 months ago
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
schemaPublished by fabian-hiller 9 months ago
Many thanks to @WtfJoke, @dboune, @alexabw and @aypotu for contributing to this release.
enum_
and enumAsync
schema by caching valuesunion
, unionAsync
, variant
and variantAsync
to improve developer experiencegetDefaults
, getDefaultsAsync
, getFallbacks
and getFallbacksAsync
for falsy but not undefined
values (issue #356)pipe
argument at union
, unionAsync
, variant
and variantAsync
union
, unionAsync
, variant
and variantAsync
(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(''),
]);
Published by fabian-hiller 10 months ago
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
schemaPublished by fabian-hiller 10 months ago
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)Published by fabian-hiller 10 months ago
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)Published by fabian-hiller 11 months ago
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)Published by fabian-hiller 11 months ago
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)Published by fabian-hiller 11 months ago
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.
Published by fabian-hiller 12 months ago
Many thanks to @lo1tuma for contributing to this release.
never
from type signatur of strict objects and tuples (issue #234)