Docs

Zod

TypeScript-first schema validation.

What is Zod

Zod defines a schema once and gives you both runtime validation and a static TypeScript type.

Install

npm
bash
npm install zod

Usage

ts
ts
import { z } from 'zod';
const User = z.object({ name: z.string(), age: z.number().min(0) });
type User = z.infer<typeof User>;
const u = User.parse(data);

Docs

Official documentation: Zod.