JSON Schema Compliance
How xschema validates against the official JSON Schema Test Suite
xschema adapters are tested against the official JSON Schema Test Suite, ensuring reliable schema conversion across all supported validation libraries.
What is the JSON Schema Test Suite?
The JSON Schema Test Suite is the official test collection maintained by the JSON Schema organization. It's the industry standard for verifying correct implementation of the JSON Schema specification across all drafts.
Each test case provides:
- A JSON Schema definition
- Sample data to validate against the schema
- Expected validation results (valid or invalid)
The suite covers every keyword and edge case in the specification, from simple type checks to complex recursive references.
How xschema tests compliance
xschema runs compliance tests by:
- Converting each JSON Schema to native validation code (Zod, ArkType, Effect, Valibot)
- Executing the generated validator against every test case
- Comparing actual results to expected outcomes
- Reporting pass/fail statistics per keyword and draft
Tests run across all supported drafts: draft-03, draft-04, draft-06, draft-07, draft-2019-09, and draft-2020-12.
Static generation approach
Unlike runtime validators that interpret schemas on-the-fly, xschema generates static validation code at build time. This approach offers:
- Type safety: Full TypeScript type inference from schemas
- Performance: No schema parsing at runtime
- Bundle size: Only include the validation code you need
- Predictability: The same schema always generates the same code
However, static generation cannot support certain dynamic JSON Schema features that require runtime evaluation. See Unsupported Features for these limitations.
How coverage is calculated
Coverage percentages reflect real-world usability by excluding tests for features that are fundamentally incompatible with static code generation:
Coverage = Passed / (Total - Unsupported) * 100Unsupported features are JSON Schema keywords that require runtime scope tracking:
$dynamicRef/$dynamicAnchor- dynamic reference resolution$recursiveRef/$recursiveAnchor- recursive reference resolutionunevaluatedProperties/unevaluatedItemswith applicators - annotation tracking
These features are excluded because no static code generator can implement them - they require a runtime interpreter by design. A 100% coverage score means the adapter handles every test case that can possibly be supported through static code generation.
Why exclude unsupported features?
Counting unsupported features as failures would penalize adapters for something impossible to fix. The coverage metric measures how well an adapter handles the schemas you'll actually use in practice.
Understanding results
Each adapter's compliance report shows:
| Term | Meaning |
|---|---|
| Passed | Tests where the generated validator produces correct results |
| Failed | Tests with unexpected behavior (potential bugs to investigate) |
| Unsupported | Tests excluded due to fundamental static generation limitations |
| Coverage | Pass rate: Passed / (Total - Unsupported) * 100 |
A coverage of 98%+ means the adapter handles nearly all practical JSON Schema use cases correctly.