zod-schemas

Create Zod validation schemas for API inputs, DTOs, env parsers, and worker job payloads.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/gengirish/dropflow --skill zod-schemas-gengirish
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: zod-schemas
Source: https://github.com/gengirish/dropflow/tree/main/.cursor/skills/zod-schemas
Command: npx skills add https://github.com/gengirish/dropflow --skill zod-schemas-gengirish

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires zod.

What problem does it solve? Defining consistent runtime validation across API boundaries, environment variables, and background job payloads is error-prone when done ad hoc. This Skill provides standardized Zod schema patterns for the DropFlow monorepo so every input is validated at the boundary with shared, type-safe definitions. ## Core Features & Use Cases - Input Schema + DTO Pattern: Define paired schemas where CreateOrderInput validates client data and OrderDTO shapes API responses, with inferred TypeScript types exported from packages/types. - Indian Localization Conventions: Built-in patterns for +91 phone numbers, 6-digit PIN codes, GSTIN format, and integer-paise money handling with dual formatted responses. - Environment & Worker Payload Validation: Parse process.env with a strict Zod schema and validate worker job payloads (orders, invoices) before processing. - Use Case: When adding a new API route that accepts order creation requests, use this Skill to generate the input schema, DTO, and inferred types following the established packages/types conventions. ## Quick Start Create a Zod input schema and DTO for a new shipment tracking endpoint following the DropFlow patterns in packages/types.

Frequently Asked Questions about zod-schemas

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Zod schema with inferred TypeScript types?▼

Define the schema with z.object(), then export the type using z.infer<typeof SchemaName>. Name both identically, such as CreateOrderInput for both the schema and its inferred type, and export both from packages/types.

How to validate environment variables with Zod in Node.js?▼

Define an envSchema with z.object() covering each variable, using validators like z.string().url() or z.enum() for NODE_ENV. Call envSchema.parse(process.env) once at startup so invalid configuration fails immediately.

How do I validate Indian phone numbers and GSTIN with Zod?▼

Use z.string().regex() with the pattern /^\+91\d{10}$/ for phone numbers and the 15-character GSTIN regex for tax identifiers. PIN codes use /^\d{6}$/ with a custom error message.

Should I use z.enum or z.nativeEnum for Prisma enums?▼

Use z.nativeEnum() for Prisma enums like OrderStatus so the schema stays in sync with the database definition. Reserve z.enum() for fixed string literal sets such as currency codes or job actions.

Why should money be stored as integer paise instead of floats?▼

Floating-point arithmetic introduces rounding errors in currency calculations. The convention uses z.number().int().nonnegative() for paise amounts and pairs them with a formatted string like ₹1,23,456.00 for display.

Where should Zod validation happen in an API workflow?▼

Validate at every trust boundary: API routes, server actions, and worker job entry points. Never trust data past the boundary; always parse with Zod first before passing it deeper into the application.