What is Zod?
Type-Safe Schema
Auto TypeScript type inference - No separate type definition needed
Runtime Validation
Actual data validation at execution - Block invalid data
Detailed Errors
Field-by-field error messages - Easy debugging
Transform & Defaults
Data transformation and defaults - Flexible handling
Basic Usage
Zod schemas are auto-generated from Entities, but you can also define them manually.Schema Definition
Data Validation
parse vs safeParse:
parse(): Throws errors. Handle with try-catchsafeParse(): Returns errors. Check with result.success
parse() in API handlers to automatically return 400 errors, and use safeParse() in UI for safe handling.