Practise the new vocabulary introduced in Zod v4, including performance improvements to z.object(), the new z.interface() type, .overwrite() transforms, .meta() metadata, and enhanced discriminated unions.
0 / 5 completed
1 / 5
What major performance improvement does Zod v4 bring to z.object()?
Zod v4's z.object() was rewritten with a focus on allocation reduction and fast-path parsing, delivering roughly 14× throughput improvement over v3 in benchmarks. This makes it practical even for high-frequency validation in hot paths like HTTP request handlers.
2 / 5
What is z.interface() in Zod v4 and how does it differ from z.object()?
z.interface() was introduced in Zod v4 as a counterpart to z.object(). It models open object types that passthrough unknown properties by default, mirroring TypeScript interface assignability semantics. z.object() remains strict/stripping by default.
3 / 5
What does the .overwrite() method do in Zod v4?
.overwrite() is a Zod v4 transform method that replaces the parsed output with a new value computed from the input. Unlike .transform(), it keeps the output type as the same as the input type, making it useful for normalisations like trimming strings without changing the inferred type.
4 / 5
How do you attach metadata (e.g., title, description) to a Zod v4 schema using .meta()?
Zod v4 introduces .meta() as the official way to attach arbitrary metadata to a schema. z.string().meta({ title: 'Name', description: '...' }) stores the metadata on the schema object and is used by JSON Schema generators and documentation tools. The older .describe() still works but .meta() is more expressive.
5 / 5
What improvement does Zod v4 make to z.discriminatedUnion()?
z.discriminatedUnion() in Zod v4 supports multiple discriminant keys, allowing compound discrimination like z.discriminatedUnion(['type', 'version'], [...]). It also gained performance improvements and better error messages that identify which discriminant key failed to match.