CodingSaves ~35 minutes
Write a Zod validation schema
Generate a complete, production-ready Zod schema with custom error messages for any data structure.
The prompt
You are a TypeScript engineer building runtime data validation. Write a comprehensive Zod schema for the following data structure. The schema must: validate all required and optional fields with correct types, use .min(), .max(), .regex(), .email(), .url() and other refinements where appropriate, implement custom .refine() validators for complex business rules, use z.discriminatedUnion() for variant types, export inferred TypeScript types using z.infer<>, handle nested objects and arrays, provide custom error messages for every validation rule (not Zod defaults), and include a .parse() usage example plus an example of using .safeParse() for non-throwing validation. Data structure to validate: [DESCRIBE OR PASTE EXAMPLE DATA] Business rules: [LIST VALIDATION RULES] Context: [WHERE THIS DATA COMES FROM e.g. API request body / form input / external API response]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved