Solid · Options
constraints
Sets how much of the schema a value is validated against: kind, the default, checks only its type. With finalize each completed field is also parsed with its own sub-schema, and the whole value once more at the closing brace, so one violation is reported at its path and again at the root. A value that violates a constraint is reported and stays in the current value.
z.object({
member: z.string(),
pass: z.enum(['season', 'none']),
seats: z.array(z.string()),
})[
'{"member":"Grace",',
'"pass":"gold",',
'"seats":["C4","C5"]}',
]{
kind: { errors: [], pass: 'gold' },
finalize: {
errors: [
{
path: 'pass',
phase: 'finalize',
message: 'Invalid option: expected one of "season"|"none"',
},
{
path: '',
phase: 'finalize',
message: 'Invalid option: expected one of "season"|"none"',
},
],
pass: 'gold',
},
}Runs in this page on the installed package. The input and the expected output are defined by the example.