validation schema
A description of what valid data looks like, checked by code while the program runs so bad data is rejected at the door.
In more detail
A schema says, for example, that email must be a valid email address and age a whole number of at least 18. Unlike TypeScript types it runs at run time, so it can check requests, responses, forms and environment variables. Keeping schemas in one shared package means client and server always enforce the same rules.
Related terms
- Zod — A TypeScript library for declaring validation schemas that check data at run time and also produce matching static types.
- input validation — Checking that data from a user, file or caller is acceptable before using it, and rejecting or asking again if not.
- JSON Schema — A standard vocabulary for describing the allowed shape of JSON data: which fields exist, their types, which are required and what values are allowed.
- type inference — The compiler working out a type from the code itself, so you do not have to write it out by hand.
- untrusted input — Any data a program did not create itself, including arguments, form fields, request bodies, file contents, file names and environment variables.
- input sanitization — Cleaning input by removing or escaping dangerous parts, such as HTML tags, before storing or displaying it.
Taught in
- End-to-End Type Safety: Shared Schemas & DTOs — Production Full-Stack Engineering
- Environment Configuration: Secrets & Multi-Stage — Production Full-Stack Engineering
- API Contract Architecture: OpenAPI 3.1 & Schema Truth — Production Full-Stack Engineering
- Type-Safe RPC Architectures: tRPC & Procedures — Production Full-Stack Engineering
- Server Action Security: Zod Validation & Auth Gates — Next.js 15 & Modern App Router Architecture