zaggino/z-schema/validating-json-data
- community
Checking that the SKILL.md file is still in the repository.
Validates JSON data against JSON Schema using the z-schema library. Use when the user needs to validate JSON, check data against a schema, handle validation errors, use custom format validators, work with JSON Schema drafts 04 through 2020-12, set up z-schema in a project, compile schemas with cross-references, resolve remote $ref, configure validation options, or inspect error details. Covers sync/async modes, safe error handling, schema pre-compilation, remote references, TypeScript types, and browser/UMD usage.
Install
npx vskill@latest install zaggino/z-schema/validating-json-dataSKILL.md
Validating JSON Data with z-schema
z-schema validates JSON data against JSON Schema (draft-04, draft-06, draft-07, draft-2019-09, draft-2020-12). Default draft: draft-2020-12.
Quick start
Install: npm install z-schema
Choosing a validation mode
z-schema has four modes based on two toggles: async and safe. Pick the one that fits the use case.
| Mode | Factory call | Returns | Use when | |
|---|---|---|---|---|
| Sync throw | ZSchema.create() | true or throws ValidateError | Default — simple scripts and middleware | |
| Sync safe | ZSchema.create({ safe: true }) | { valid, err? } | Need to inspect errors without try/catch | |
| Async throw | ZSchema.create({ async: true }) | Promise<true> or rejects | Using async format validators | |
| Async safe | ZSchema.create({ async: true, safe: true }) | Promise<{ valid, err? }> | Async + non-throwing |
Sync throw (default)
Sync safe
Or call .validateSafe() on a regular (throwing) validator for the same result shape:
Async throw
Required when using async format validators.
Async safe
Inspecting errors
ValidateError has .details — an array of SchemaErrorDetail:
Example: walking nested errors
Combinators (anyOf, oneOf, not) produce nested inner errors:
Filtering errors
Pass ValidateOptions as the third argument to include or exclude specific error codes:
For the full error code list, see references/error-codes.md.
Schema pre-compilation
Compile schemas at startup for better runtime performance and to resolve cross-references:
Remote references
Manual registration
Automatic loading via schema reader
Diagnosing missing references
Custom format validators
Global (shared across all validator instances)
Instance-scoped
Via options at creation time
Async format validators
Return Promise<boolean>. Requires { async: true }.
Listing registered formats
Choosing a draft version
Set the draft explicitly if the schema targets a specific version:
Valid values: 'draft-04', 'draft-06', 'draft-07', 'draft2019-09', 'draft2020-12' (default), 'none'.
For a feature comparison across drafts, see references/draft-comparison.md.
Common options
| Option | Default | Purpose | |
|---|---|---|---|
breakOnFirstError | false | Stop validation at the first error | |
noEmptyStrings | false | Reject empty strings as type string | |
noEmptyArrays | false | Reject empty arrays as type array | |
strictMode | false | Enable all strict checks at once | |
ignoreUnknownFormats | false | Suppress unknown format errors (modern drafts always ignore) | |
formatAssertions | null | null=always assert, true=respect vocabulary, false=annotation-only | |
reportPathAsArray | false | Report error paths as arrays instead of JSON Pointer strings |
For the full options reference, see references/options.md.
Validating sub-schemas
Target a specific path within a schema:
Browser usage (UMD)
TypeScript types
All types are exported from the package:
Reference files
- references/error-codes.md — Full error code list with descriptions and examples
- references/options.md — Complete options reference with defaults
- references/draft-comparison.md — Feature comparison across JSON Schema drafts
Important conventions
- Always use
ZSchema.create(options?)— nevernew ZSchema(). The factory returns the correctly typed variant. - Error details are on
.details(not.errors). - Import types with
import type { ... }and values withimport { ValidateError }. - Default draft is
draft2020-12. Specify explicitly if targeting an older draft.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/validating-json-data/SKILL.md
Popularity
- Repository stars
- 350
- Repository forks
- 91
- Repository npm downloads, 7 days
- 3,241,985
- 7-day trend score
- 62
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 1 Apr 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/zaggino/z-schema/validating-json-data)