Reputation: 282865
This question pertains to ajv.
How can I get the schema being validated?
e.g.
const validatePromise = ajv.compileAsync({...options.schema, $async: true});
validatePromise.then(validate => {
validate(value).then(() => {
// validation was successful
}, errResult => {
if(errResult instanceof Ajv.ValidationError) {
// how to get the schema?
}
})
});
Before you tell me to just put {...options.schema, $async: true}
into a variable, remember that remote schemas can be loaded -- I want the fully-resolved schema with all of its rules and properties. Presumably all of the subschemas have loaded before errResult
can be computed -- so where is it stored and how do I access it?
Upvotes: 2
Views: 1431