Releases: badrap/valita
Releases · badrap/valita
v0.3.11
Patch Changes
-
f78c082
Thanks @jviide! - Add experimental support for.optional(() => x)
The
.optional()
method now supports default value functions for replacingundefined
and missing values from the input and wrapped validator. The functionality is similar to.default(x)
, except thatdefaultFn
has to be a function and is executed for each validation run. This allows patterns like the following:const Item = v.object({ id: v.string() }); const Items = v.array(Item).optional(() => []);
This avoids a common pitfall with using
.default([])
for the same pattern. As the newly created empty arrays are not shared, mutating them is safe(r) as it doesn't affect other validation outputs.This feature is marked experimental for the time being.
v0.3.10
v0.3.9
v0.3.8
v0.3.6
- Generate provenance statements for npm.
- Functions passed to
.chain(...)
,.map(...)
and.assert(...)
now receive a second parameter, useful for forwarding the current parsing mode to.try(...)
.
v0.3.5
- Republish to get JSR provenance statements.
v0.3.4
v0.3.3
v0.3.2
Full Changelog: v0.3.1...v0.3.2