rule-zod

Enforce Zod schema authoring with strictObject, safeExtend, and meta() for IPFS data validation.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Zod schema authoring in large projects often suffers from inconsistent shapes, optional fields being misused, and missing standardization for metadata. This Skill defines a disciplined pattern using z.strictObject(), .safeExtend(), and .meta() to create predictable, well-documented schema layers that map to IPFS/NFT data models.

Core Features & Use Cases

  • Enforces strict object schemas to reject unknown properties at parse time for data integrity.
  • Enables safe, layered composition via .safeExtend() instead of in-place merges to preserve strictness.
  • Ensures field-level documentation through .meta() on every field to support auto-generated docs and UX.
  • Use Case: when adding a new NFT IPFS schema, start from a BaseIpfsSchema and progressively extend to MassIDNftIpfsSchema with clear metadata.

Quick Start

Define a BaseIpfsSchema and extend it with NftIpfsSchema and MassIDNftIpfsSchema using z.strictObject(), .safeExtend(), and .meta() on each field.

Frequently Asked Questions about rule-zod

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

FAQPage Schema
How do I enforce strict Zod schemas to reject unknown properties during IPFS data validation?

Strict Zod schemas enforce IPFS data validation by using z.strictObject() to reject unknown properties at parse time. This approach ensures data integrity by preventing unexpected fields from passing validation in TypeScript models.

What is the best way to compose layered Zod schemas for NFT data models?

The best way to compose layered Zod schemas for NFT data models is using .safeExtend() instead of in-place merges. This preserves strictness while allowing progressive extension from a BaseIpfsSchema to specific schemas like MassIDNftIpfsSchema.

How do I document Zod schema fields for auto-generated docs and UX?

Document Zod schema fields by applying .meta() on every field. This enforces field-level documentation to support auto-generated docs and UX, ensuring consistent metadata across all NFT and IPFS data attributes.

Why does .merge() break strict object validation in Zod?

Using .merge() can break strict object validation because it may lose the strictness enforced by z.strictObject(). Prefer .safeExtend() over .merge() to maintain consistent rejection of unknown properties during schema composition.

Does this Zod validation pattern apply to all TypeScript schema files?

This Zod validation pattern applies to src/**/*.schema.ts and src/**/*.schemas.ts files. It guides the development of layered, type-safe schemas across NFT and IPFS models to maintain consistent data validation standards.