z.string().email(). Zod validates the format. For stronger validation, you can chain .refine with a custom check (e.g., block disposable email providers).
How do I validate an email in Zod?
More FAQs in How to Write an Express Validation Middleware With Zod
Define a Zod schema, write a validate(schema) middleware factory that uses safeParse, returns 400 with errors if invalid, replaces req.body with parsed data if valid, and calls next. Apply per route: router.post('/signup', validate(signupSchema), signup).
TypeScript inference, great error messages, composable schemas, safe parse (returns success or error instead of throwing), and built-in types. It is one of the best modern validators for Node.js.
Same pattern, but validate req.params. Example: const idSchema = z.object({ id: z.string().length(24) }); router.get('/users/:id', validateParams(idSchema), getUser). Use a separate factory that reads req.params.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.