What is Zod?
mainZod is a TypeScript-first schema declaration and validation library. It allows you to define a schema (representing any data type from a simple string to a complex nested object) once, and then automatically infer the static TypeScript type from it. This eliminates the need for duplicative type declarations.
Key features include:
- Zero dependencies: Lightweight and secure.
- Environment agnostic: Works in Node.js and all modern browsers.
- Tiny footprint: Approximately 8kb minified + zipped.
- Immutable: Methods like
.optional()return a new instance rather than mutating the original. - Functional approach: Follows the "parse, don't validate" philosophy.
- JavaScript compatible: Can be used in plain JavaScript projects without TypeScript.