zod-best-practices
/zod-best-practices
Stosuje konwencje Zod v4 dla własnych kontraktów danych i jawnych wyników walidacji, przy definiowaniu i przeglądzie schematów oraz parsowaniu niezaufanych danych.
- Autor
- Casper-Studios ↗
- Repozytorium
- casper-marketplace ↗
- Licencja
- MPL-2.0
- Ostatnia zmiana repozytorium
- 05.09.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 16
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 1
Brak sygnałów. Repozytorium zmienione 05.09.2026, bez odwołań do wycofanych modeli i API.
MPL-2.0, otwarta.
Co robi i kiedy
Stosuje konwencje Zod v4 dla własnych kontraktów danych i jawnych wyników walidacji, przy definiowaniu i przeglądzie schematów oraz parsowaniu niezaufanych danych.
Oryginalny opis (EN)
Zod v4 conventions for owned wire contracts and explicit validation outcomes. Use when defining or reviewing Zod schemas or parsing untrusted data with Zod.
Jak działa
- Library Sources
- Effective Strategies for Zod
Podgląd SKILL.md
--- name: zod-best-practices description: Zod v4 conventions for owned wire contracts and explicit validation outcomes. Use when defining or reviewing Zod schemas or parsing untrusted data with Zod. license: MPL-2.0 metadata: author: 'Basti Ortiz <ortiz@bastidood.dev>' source: 'https://github.com/BastiDood/skills' --- # Zod Best Practices Treat a Zod schema as the owned contract at an untrusted data boundary: it defines accepted wire values, produces trusted domain values, and makes invalid input an explicit, intentional outcome. ## Library Sources - GitHub repository ID: `colinhacks/zod` - Context7 library ID: `/colinhacks/zod` - DeepWiki repository ID: `colinhacks/zod` Use Context7 for current documentation and DeepWiki for implementation details. ## Effective Strategies for Zod Read the references that apply to the current task before defining or reviewing Zod schemas and parsing code. 1. Make schemas the owned, trusted contract for wire data. - [Keep a schema and its standard string formats as the single source of truth](./references/schema-ownership-and-formats.md) instead of duplicating types or custom format logic. - [Validate serialized data at its trust boundary](./references/serialized-trust-boundaries.md), including authenticated external payloads, before it becomes a domain value. - [Keep constructors and format validators under one `z` import](./references/zod-imports.md) rather than mixing import forms. - [Infer the correct side of a schema](./references/schema-input-output.md) with `z.input` or `z.infer` when a transform or default changes accepted input from parsed output instead of hand-writing either type. 2. Express the complete protocol contract in the schema. - [Select Zod's top-level validator for a standard string format](./references/top-level-formats.md) instead of recreating the format with a custom regular expression. - [Encode missing and `null` wire semantics](./references/wire-nullability.md) with the matching wrapper rather than whichever wrapper compiles. - [Define defaults with exact domain meaning in the schema](./references/schema-defaults.md); do not use defaults to turn unknown or invalid input into arbitrary fallbacks. - [Dispatch literal-tagged alternatives with `z.discriminatedUnion`](./references/discriminated-unions.md) rather than trying each tagged branch with `z.union`. - [Select the matching object constructor when unknown keys have contract meaning](./references/object-strictness.md): strip for leniency, reject for closed contracts, or preserve only opaque pass-through data. 3. Make validation failure match the boundary and presentation contracts. - [Choose the parse API from the failure contract](./references/parse-failure-contracts.md): abort a violated invariant or return an expected validation branch. - [Derive expected validation presentation from Zod's error](./references/validation-error-rendering.md) instead of discarding its field information. - [Use `.refine()` for one value and one boolean rule](./references/predicate-validation.md); move multi-field or multi-issue validation to `.check()`. - [Use `.check()` for multi-field relationships with separate actionable issues](./references/cross-field-validation.md) instead of collapsing them into one `.refine()` error.
Pliki w paczce (16)
- LICENSE.txt 16 KB
- SKILL.md 3 KB
- agents/openai.yaml 1 KB
- references/cross-field-validation.md 2 KB
- references/discriminated-unions.md 1 KB
- references/object-strictness.md 1 KB
- references/parse-failure-contracts.md 1 KB
- references/predicate-validation.md 1 KB
- references/schema-defaults.md 1 KB
- references/schema-input-output.md 1 KB
- references/schema-ownership-and-formats.md 1 KB
- references/serialized-trust-boundaries.md 1 KB
- references/top-level-formats.md 1 KB
- references/validation-error-rendering.md 1 KB
- references/wire-nullability.md 1 KB
- references/zod-imports.md 1 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · Casper-Studios/casper-marketplace | 100 | MPL-2.0 |
| bastidood/skills | 100 | MPL-2.0 |
Migawka bazy z 13.11.2026 · wersja paczki 95180be4a1fd (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 3 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 90valibot-best-practices
Opisuje konwencje Valibot dla własnych kontraktów danych i jawnych wyników walidacji przy definiowaniu schematów lub parsowaniu niezaufanych danych. - 90valibot-best-practices
Podpowiada, jak pisać i sprawdzać schematy Valibot dla kontraktów sieciowych oraz niezaufanych danych wejściowych. - 95zod-patterns
Stosuje wzorce schematów Zod z projektu Mix Space przy tworzeniu DTO i walidacji żądań. - 90zod
Stosuje konwencje projektu Esposter przy pisaniu schematów Zod: kształt schematu, parsowanie na granicach systemu i ograniczenia wartości. - 100zod
Pomaga stosować Zod do walidacji w TypeScripcie: parsowania danych API, formularzy, konfiguracji środowiska i typów z z.infer. - 92zod-v4
Zawiera wytyczne kodowania Zod v4 i przewodnik migracji z v3 przy pisaniu, przeglądzie i migracji kodu.