Replies: 1 comment
|
No —
So To make a property accept any value AND be optional: import * as v from 'valibot';
const Schema = v.object({
required_any: v.unknown(), // required, any value
optional_typed: v.optional(v.string()), // optional, must be string if present
optional_any: v.optional(v.unknown()), // optional, any value if present
});
// All three parse successfully:
v.parse(Schema, { required_any: 42 });
v.parse(Schema, { required_any: 42, optional_typed: 'hello' });
v.parse(Schema, { required_any: 42, optional_any: { nested: true } });
// This fails — required_any is missing:
v.parse(Schema, {});Summary:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Moved to https://discord.com/channels/1252985447273992222/1255508856608522341/1255508856608522341
All reactions