zod-4

Upgrade Zod 3 schemas to Zod 4 with TypeScript validation examples.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod-4 schema validation patterns and migration guidance for developers moving from Zod v3 to v4, clarifying breaking changes and common upgrade paths.

Core Features & Use Cases

  • Provides a concise reference of top-level validators, object schemas, arrays, unions, transformations, and refinements in Zod 4.
  • Demonstrates error handling and mapping strategies to improve user feedback and reliability in TypeScript projects.
  • Useful for teams upgrading APIs, forms, and data pipelines to Zod 4 with minimal disruption.

Quick Start

Upgrade existing Zod 3 schemas to Zod 4 using the provided examples and patterns.

Frequently Asked Questions about zod-4

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

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

To migrate TypeScript validation schemas from Zod 3 to Zod 4, use the provided guidance to update declarative validators, object schemas, and unions while resolving breaking changes for minimal disruption.

How does error handling work for Zod 4 schema validation in TypeScript?

Error handling in Zod 4 schema validation uses mapping strategies to improve user feedback and reliability. It provides structured error mapping for TypeScript projects to clarify validation failures across APIs and forms.

What are the new patterns for defining unions and transformations in Zod 4?

Defining unions and transformations in Zod 4 involves updated declarative validators and refinement patterns. These schemas allow complex data processing pipelines to validate and transform inputs robustly within TypeScript.

Can I use Zod 4 schema validation for API and form data pipelines?

Yes, Zod 4 schema validation is applicable for APIs, form validation, and data processing pipelines. It provides declarative validators and object schemas to enforce robust validation rules in TypeScript projects.

What are common breaking changes when upgrading to Zod 4?

Common breaking changes when upgrading to Zod 4 involve modifications to top-level validators, object schemas, and refinements. The migration guidance clarifies these changes and outlines common upgrade paths for TypeScript projects.