Runtime validation (Zod)
Checking at run time that data from outside (requests, APIs, files, models) matches the type your code assumes.
TypeScript types disappear after compilation, so they cannot stop a malformed request body. A schema library such as Zod describes the shape once, validates the data at the boundary and gives you the static type for free. Inside the boundary the code can trust its types; outside it, nothing is trusted.
Related terms
- Discriminated union: A TypeScript type made of variants that share one literal field, so the compiler knows which variant you have.
- Structured outputs: The model’s answer is constrained to match a JSON schema you provide.
- Webhook: An HTTP request one system sends to another when something happens, instead of the other system asking repeatedly.
