Solid · Options

mode

Sets how the stream handles a value of the wrong type. recover, the default, rejects the value, keeps the previous one and continues parsing, while strict stops the stream at it. trust validates nothing: in the example a string ends up in seats, where the schema expects an array.

Schema
z.object({
  show: z.string(),
  night: z.string(),
  seats: z.array(z.string()),
  price_cents: z.number(),
  why: z.string(),
})
Chunks
[
  '{"show":"The Tempest","night":"2026-10-24",',
  '"seats":"C4 and C5",',
  '"price_cents":7600,"why":"Two seats together."}',
]
Value and error count by mode
{
  recover: { seats: [], price_cents: 7600, errorCount: 1 },
  strict: { seats: [], price_cents: 0, errorCount: 1 },
  trust: { seats: 'C4 and C5', price_cents: 7600, errorCount: 0 },
}
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.