← ClaudeAtlas

zod-validation-utilitieslisted

Creates reusable Zod v4 schemas, validates API payloads, forms, and configuration input, transforms and coerces data safely, and handles validation errors with strong type inference for TypeScript applications. Use when designing validation layers, parsing `z.string()`, `z.object()`, or `z.email()` schemas, or implementing runtime type-safe data validation.
giuseppe-trisciuoglio/developer-kit · ★ 371 · AI & Automation · score 88
Install: claude install-skill giuseppe-trisciuoglio/developer-kit
# Zod Validation Utilities ## Overview Production-ready Zod v4 patterns for reusable, type-safe validation with minimal boilerplate. Focuses on modern APIs, predictable error handling, and form integration. ## When to Use - Defining request/response validation schemas in TypeScript services - Parsing untrusted input from APIs, forms, env vars, or external systems - Standardizing coercion, transforms, and cross-field validation - Building reusable schema utilities across teams - Integrating React Hook Form with Zod using `zodResolver` ## Instructions 1. Start with strict object schemas and explicit field constraints 2. Prefer modern Zod v4 APIs and the `error` option for error messages 3. Use coercion at boundaries (`z.coerce.*`) when input types are uncertain 4. Keep business invariants in `refine`/`superRefine` close to schema definitions 5. Export both schema and inferred types (`z.input`/`z.output`) for consistency 6. Reuse utility schemas (email, id, dates, pagination) to reduce duplication ## Validation Workflow When integrating validation into an API handler or service: 1. **Define** the schema at the boundary (handler, queue, config loader) 2. **Parse** with `safeParse` to handle errors gracefully 3. **Check** `result.success` to branch on failure/success 4. **Use** `result.data` with full type inference in success path 5. **Return** formatted errors or proceed with validated data See example 7 (`safeParse` workflow) for the complete pattern. ## Examples ##