Zod
npm install zod// tsconfig.json
{
// ...
"compilerOptions": {
// ...
"strict": true
}
}Usage
import { z } from "zod";
const User = z.object({
username: z.string(),
});
User.parse({ username: "Ludwig" });
// extract the inferred type
type User = z.infer<typeof User>;
// { username: string }Types
Primitatives
Last updated