zod-4

Migrate Zod v3 validation logic to Zod v4 with updated schema patterns.

2|Updated Jul 29, 2025
One-click install
npx skills add https://github.com/kurojs/ender4-dots --skill zod-4-kurojs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-4
Source: https://github.com/kurojs/ender4-dots/tree/main/.config/opencode/skill/zod-4
Command: npx skills add https://github.com/kurojs/ender4-dots --skill zod-4-kurojs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This guide assists developers migrating validation logic from Zod v3 to Zod v4, consolidating patterns to avoid breaking changes and maintain consistency.

Core Features & Use Cases

  • Updated primitives and top-level validators: z.email(), z.uuid(), z.url(), and z.string().min(...) for common constraints, plus z.object for shapes.
  • Comprehensive schema coverage: validation patterns for objects, arrays, unions, refinements, and error handling aligned with Zod 4 APIs.
  • Migration guidance with examples: side-by-side v3 vs v4 code snippets showing equivalent schemas and parsing results.
  • Transformations and error handling: support for coercions, preprocess, and clear error mapping in Zod 4 style.

Quick Start

Update your Zod 3 schemas to Zod 4 by replacing old APIs with top-level validators (z.email, z.uuid, z.url) and adapting object schemas and error handling.

Frequently Asked Questions about zod-4

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

FAQPage Schema
How do I migrate Zod schemas from v3 to v4?

Migrating Zod schemas from v3 to v4 involves replacing old string validation APIs with top-level validators like z.email, z.uuid, and z.url, and updating object schemas and error handling to match Zod 4 APIs.

What are the top-level validators introduced in Zod 4?

Top-level validators in Zod 4 include z.email, z.uuid, and z.url, which replace older string-based validation patterns to provide standardized runtime validation for common data formats.

How do I handle transformations and coercions in Zod 4?

Handle transformations and coercions in Zod 4 by utilizing updated preprocess and coercion APIs, ensuring refined error mapping compatible with Zod 4 style for consistent parsing results.

Can I use Zod 4 for runtime validation of complex TypeScript objects and arrays?

Zod 4 supports runtime validation for complex TypeScript data models including objects, arrays, and unions, using z.object for shapes and refinements for custom constraints.

What is the best way to update error handling when migrating to Zod 4?

The best way to update error handling during a Zod 4 migration is to adapt to its refined error mapping style, ensuring consistent error handling across validation pipelines and transformations.