Skip to content

Glossary: TypeScript Beyond the Basics

z.coerce

Also written: z.coerce.number(), coercion

A Zod schema that converts the value first (for example with `Number()`) and then checks it. `"3"` becomes `3`, and `"abc"` fails; it suits text from forms and environment variables.

Where the book teaches it

Related terms

Environment variableSchema