Zod validation schema guide. Use when creating validators, organizing validation schemas, integrating Drizzle-Zod for database schemas, implementing custom refinements, or creating shared reusable schemas.
This skill covers creating and organizing Zod validation schemas that are shared between frontend forms and backend API routes. It includes standard validator creation, schema organization by feature, Drizzle-Zod integration for generating schemas from database tables, custom refinements for complex validation rules, and building shared reusable schema primitives.
/validators/[feature].ts with proper exportscreateInsertSchema and createSelectSchema.refine(), .superRefine(), and .transform()/validators/[feature].ts. Never define Zod schemas inline in route handlers or components.z.infer<typeof schema>.zodResolver and the oRPC .input() must use the identical schema..pick(), .omit(), .extend(), and .merge() to derive variants from a base schema..input()zodResolver