name: json-schema-validator description: Validate JSON objects against schemas with clear error reporting
JSON Schema Validation
Task Overview
Validate JSON objects against a schema and report all errors clearly.
Core Rules
- Check all required fields exist
- Validate types match schema
- Check string patterns (if specified)
- Validate numeric ranges
- Recursively validate nested objects
Error Format
Report errors as:
- Path: field.subfield
- Issue: what's wrong
- Expected: what was expected
- Got: what was received
Common Patterns
- Email: use regex /^[^@]+@[^@]+.[^@]+$/
- Date: ISO 8601 format
- UUID: 8-4-4-4-12 hex pattern
Edge Cases
- null vs missing field (different errors)
- Empty arrays vs missing arrays
- Extra fields (warn, don't error by default)
Example
Input: {"name": 123, "email": "notanemail"} Schema: {"name": "string", "email": "email"}
Output:
- Path: name | Issue: wrong type | Expected: string | Got: number
- Path: email | Issue: invalid format | Expected: email | Got: notanemail