zod

Enforce strictObject, .meta(), and safeExtend patterns in Zod schemas.

1|Updated Apr 17, 2025
One-click install
npx skills add https://github.com/carrot-foundation/schemas --skill zod-carrot-foundation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: zod
Source: https://github.com/carrot-foundation/schemas/tree/main/.cursor/skills/zod
Command: npx skills add https://github.com/carrot-foundation/schemas --skill zod-carrot-foundation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod helps engineers define robust, type-safe schemas for data validation in TypeScript projects, reducing runtime errors and clarifying data contracts.

Core Features & Use Cases

  • Strongly typed schemas with .strictObject() to reject unknown fields
  • Rich metadata via .meta() on fields to generate docs and validation hints
  • Layered composition with safeExtend patterns for scalable schema design
  • Real-world use: validating API payloads and IPFS metadata structures

Quick Start

Create a strict, well-documented Zod schema by composing strictObject with per-field .meta() descriptors and extending base schemas as needed.

Frequently Asked Questions about zod

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

FAQPage Schema
How do I enforce strict validation and reject unknown fields in TypeScript schemas?

Strict validation in TypeScript schemas is achieved by applying strictObject, which rejects unknown fields and ensures data contracts precisely match expected payloads. This prevents extraneous data from passing silently and clarifies data structures across modules.

What is the best way to add metadata to Zod schemas for documentation?

The best way to add metadata to Zod schemas is by applying .meta() on every field. This attaches rich metadata-driven documentation and validation hints directly to the schema definition, making the data contracts self-documenting and easier to maintain.

Can I safely compose and extend Zod schemas across different modules?

Yes, you can safely compose and extend Zod schemas across modules using the safeExtend pattern. This enables layered schema composition, allowing scalable schema design by building complex types from base schemas without breaking existing validation logic.

Does this approach work for validating API payloads and IPFS metadata structures?

Yes, this schema validation approach works for validating API payloads and IPFS metadata structures. By combining strictObject with per-field .meta() descriptors, you create strongly typed schemas that validate complex nested data reliably.

Why should I use strictObject instead of standard object schemas in TypeScript?

You should use strictObject instead of standard object schemas to reject unknown fields during validation. Standard objects allow extra properties, but strictObject enforces exact data contracts, reducing runtime errors from unexpected payload properties.