Validation
json-tology validates data against registered JSON Schemas via a compiled graph engine. All validation methods accept either a schema $id string or a schema object with $id.
Methods
| Method | Returns | Use when |
|---|---|---|
instantiate | the schema's inferred type (ParseOutputType<TRefs[K], TRefs>) | You want a typed, defaults-applied value or a typed exception |
validate | ValidationErrors | You want structured error data (paths, keywords, params) |
is | boolean type guard | You need a boolean with TypeScript narrowing |
subschemaAt | sub-schema object | You need to validate a sub-schema by JSON Pointer |
Error views on ValidationErrors: see Error Views for aggregate, report, and iteration.
All examples use the bookstore domain. See Getting Started for installation.
Related
ValidationErrors- the structured error collection returned byvalidateValidationErrorsviews -aggregate,reportinstantiate- coerce + validate + apply defaults
See also
- Argument conventions - universal
SchemaRef(string or object) - Bookstore domain - schema definitions used in examples
- Picking a method - decision guide for which validation method to use