Zod v4 brings major performance improvements, new convenience validators, built-in JSON Schema generation, and a tree-shakeable zod/v4/mini entry point. These exercises cover the new and changed API surface.
0 / 5 completed
1 / 5
What is Zod Mini (zod/v4/mini) and what is its primary trade-off?
Zod Mini is an alternative entry point (import { z } from 'zod/v4/mini') with a smaller footprint achieved through tree-shaking. The trade-off is a functional API — methods like z.optional(z.string()) replace z.string().optional(). This makes every helper individually importable and eliminates unused validators from the bundle.
2 / 5
What does z.email() produce in Zod v4?
z.email() in Zod v4 is syntactic sugar for z.string().email(). Similarly, z.url() shortens z.string().url(). These convenience factories reduce boilerplate for the most common string format validations.
3 / 5
What is the purpose of z.input and z.output in Zod v4?
z.input<S> extracts the TypeScript type of values accepted by the schema (before any .transform()), while z.output<S> extracts the type after transformation. These are equivalent to the existing z.infer (which resolves to z.output) but make the distinction explicit when transforms change the type.
4 / 5
How does Zod v4 improve error message customisation compared to v3?
Zod v4's error customisation is centralised: you can pass an error string or function directly on any schema or refinement method, and z.config({ customError: ... }) sets a global error map. This replaces v3's z.setErrorMap() and scattered message options with a consistent, composable API.
5 / 5
What does the .meta() method added to Zod v4 schemas enable?
.meta() stores arbitrary metadata on a schema without affecting its validation behaviour. Fields like title, description, examples, and deprecated are picked up by z.toJSONSchema() (the new built-in JSON Schema generator) and by OpenAPI generators, replacing the community workaround of using .describe() for everything.