Default values
guillaumervls opened this issue Β· comments
Package version
1.7.1
Describe the bug
Hi and thanks for the work on VineJS!
Is there a way to add a transform/mutation to specify a default value when something is optional / undefined
?
Like Zod's .default
:
const stringWithDefault = z.string().default("tuna");
stringWithDefault.parse(undefined); // => "tuna"
Cheers!
Reproduction repo
No response
Thanks for your answer @RomainLanz! π
(BTW, feel free to close/keep this issue depending on whether you're considering adding a dedicated function or not.)
The parse
method is a bit more verbose, but it is also way more powerful, so we are not going to extend Vine's API to add a new default
method.
Closing. ππ»