zod-validation-utilities

Solid

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.

AI & Automation 263 stars 31 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
81
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 ##...

Details

Author
giuseppe-trisciuoglio
Repository
giuseppe-trisciuoglio/developer-kit
Created
7 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category