Schema Validation with Zod

Definition

Zod allows you to define a schema and infer types from it.

import { z } from "zod";

const User = z.object({
  username: z.string(),
});

type User = z.infer<typeof User>;

Great for form validation and API response parsing.