validate performs JSON Typedef validation of an instance (or "input") against a JSON Typedef schema, returning a standardized set of errors.
This function may throw MaxDepthExceededError if you have configured a ValidationConfig.maxDepth. If you do not configure such a maxDepth, then this function may cause a stack overflow. That's because of circularly-defined schemas like this one:
{
"ref": "loop",
"definitions": {
"loop": { "ref": "loop" }
}
}
If your schema is not circularly defined like this, then there is no risk for validate to overflow the stack.
If you are only interested in a certain number of error messages, consider using ValidationConfig.maxErrors to get better performance. For instance, if all you care about is whether the input is OK or if it has errors, you may want to set maxErrors to 1.
The schema to validate data against
The "input" to validate
Validation options. Optional.
Generated using TypeDoc
Module validate provides an implementation of JSON Typedef validation.
The most important function in this module is validate, which returns an array of ValidationError. You can configure validate by passing it a ValidationConfig.