Solid · CompletionValidation on completion (
Validation on completion (finalize)
With constraints: 'finalize' each constraint in the schema is validated once, against the completed value of its field. In the example the half-written booking string does not match its regex and no error is reported. seats is 6 where the schema allows at most 4, and that error is reported when the next key is named.
createStream({
schema: z.object({
booking: z.string().regex(/^B-\d{4}$/),
seats: z.number().max(4),
why: z.string(),
}),
initial: { booking: 'B-0000', seats: 1, why: '' },
constraints: 'finalize',
})Stream, chunk by chunk
{"booking":"B-20{ booking: 'B-20', seats: 1, errors: [] }Runs in this page on the installed package. The input and the expected output are defined by the example.