Loading...
Loading...
Zod v4 schema validation for TypeScript. Covers primitives, string formats, objects, arrays, unions, coercion, transforms, refinements, parsing, type inference, error customization, JSON Schema, file validation, and metadata. Use when writing schemas, validating input, parsing data, inferring types, or converting schemas with Zod.
npx skill4agent add oakoss/agent-skills zod-validationz.stringbool()z.iso.*z.overwrite()z.file()z.toJSONSchema().meta()errorzodzod/mini| Pattern | Usage |
|---|---|
| Define object schemas |
| Primitive types |
| Top-level string formats (v4) |
| ISO date/time formats (v4) |
| Fixed-width number formats (v4) |
| Template literal type validation (v4) |
| Enums and literals |
| Union types |
| Array and tuple types |
| Key-value collections |
| Optional and nullable modifiers |
| Default values and fallbacks |
| Pre-parse default (parsed through schema, v4) |
| Type coercion before validation |
| String-to-boolean parsing (v4) |
| Output transforms |
| Chain schemas (output feeds next input) |
| Custom validation logic |
| Validate and extract data |
| Extract TypeScript type from schema |
| Input vs output types with transforms |
| File instance validation (v4) |
| Convert schema to JSON Schema (v4) |
| Attach metadata to schemas (v4) |
| Human-readable error formatting (v4) |
| Structured error tree (replaces .format(), v4) |
| Typed schema registry (v4) |
| Unified error customization (v4) |
| Getter-based recursion | Recursive types without |
| Global schema metadata registry (v4) |
| Internationalized error messages (v4) |
| Mistake | Fix |
|---|---|
| |
| |
Using | Use |
Forgetting | Add when field may be undefined |
| Use |
| Use |
Missing | Empty strings pass |
| |
| |
| Use getter syntax in v4 (retains object methods) |
| Use unified |
| Function-as-second-arg overload removed; use |
| Replaced by |
| v4 requires two args: |
| Deprecated; use |
| v4 |