Validation with Zod

Learn Zod, the TypeScript-first schema library: define schemas, parse and validate untrusted data, infer types instead of duplicating them, and wire it all into React forms with react-hook-form.

BTaught by Brad Traversy
4.8
186 enrolled

Start learning

Build real skills one lesson at a time

Explore the complete curriculum below, then start with the lesson that is right for you.

About this course

Zod is the TypeScript-first way to validate data at runtime. You describe a shape once, and that one schema checks your data, produces clear error messages, and hands you the TypeScript type for free.

A short, focused course that takes you from your first schema all the way to a fully validated React sign-up form built with react-hook-form.

What you'll learn

  • Defining schemas and validating with parse and safeParse
  • Custom error messages your users actually read
  • Inferring TypeScript types with z.infer instead of duplicating interfaces
  • Composing schemas: objects, arrays, optional and nullable fields, enums, and schema reuse
  • Modeling variant data with discriminated unions
  • Custom rules with refine and reshaping with transform
  • Validating API responses safely at the boundary
  • Wiring schemas into React forms with react-hook-form and zodResolver, from field-level errors to a fully typed submit

Prerequisites

The lessons are written in TypeScript, and every type you need comes straight from your schemas. Want to go deeper on the type system itself? Continue with TypeScript Fundamentals (opens in a new tab).

Course instructor

BT

Brad Traversy

Founder of Traversy Media and an educator known for practical, project-focused web development courses.

Course content