zod-4

Provides Zod 4 schema patterns and migration guidance from Zod v3.

Updated Jun 22, 2024
One-click install
npx skills add https://github.com/KilloconQ/dotfiles --skill zod-4-killoconq
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod-4
Source: https://github.com/KilloconQ/dotfiles/tree/main/opencode/.config/opencode/skills/zod-4
Command: npx skills add https://github.com/KilloconQ/dotfiles --skill zod-4-killoconq

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod 4 introduces breaking changes from Zod v3 and changes in syntax and usage. This guide provides patterns and examples to help developers migrate and validate data using Zod 4 consistently.

Core Features & Use Cases

  • Migration guidance from Zod v3 to v4 for common validators (strings, numbers, dates) and schemas.
  • Comprehensive examples for primitive schemas, object schemas, arrays, unions, refinements, and transformations.
  • Clear guidance on error handling, optional/nullable values, and defaulting.

Quick Start

Create a simple Zod 4 user schema with an id as uuid, email, and name as a nonempty string.

Frequently Asked Questions about zod-4

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

FAQPage Schema
How do I migrate my TypeScript validation schemas from Zod v3 to Zod 4?

To migrate Zod schemas from v3 to Zod 4, you must update syntax for common validators like strings, numbers, and dates. This guide provides migration patterns and examples to resolve breaking changes and ensure consistent data validation across TypeScript apps.

How do I define object schemas with optional, nullable, and default values in Zod 4?

Defining object schemas in Zod 4 involves applying specific patterns for optional, nullable, and default values to handle data correctly. The guide provides comprehensive examples for structuring objects and managing error handling across TypeScript applications.

What is the best way to handle custom validation refinements and transformations in Zod 4?

Handling custom validation refinements and transformations in Zod 4 requires applying specific schema patterns to modify and validate data. The guide provides comprehensive examples for implementing refinements and transformations to ensure data integrity.

Does Zod 4 syntax work with TypeScript APIs and form validation without extra dependencies?

Zod 4 syntax works natively with TypeScript APIs and form validation without requiring extra dependencies. The guide specifies self-contained patterns with runnable examples that are compatible with TypeScript tooling and popular frameworks.

How do I resolve error handling issues when validating arrays and unions in Zod 4?

Resolving error handling issues for arrays and unions in Zod 4 requires applying the updated schema patterns and error guidance. The guide provides comprehensive examples for defining arrays, unions, and managing errors across TypeScript apps.

Why does my Zod 4 schema validation fail on primitive types like dates and numbers?

Zod 4 schema validation fails on primitives like dates and numbers due to breaking changes and syntax updates from Zod v3. You must apply the updated primitive schema patterns to resolve inconsistencies and validate data correctly.