When using ajv.compile(), how do you get line and column information about schema compile errors?
validateSchema.ts
const { data: schema, pointers } = jsonSourceMap.parse(
fsExtra.readFileSync(`${__dirname}/../my.schema.json`).toString()
);
const ajv = new Ajv({
strict: true,
allErrors: true,
verbose: true
});
ajv.compile(schema, true);
my.schema.json
{
"title": "JSON schema for names",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"deprecated": true,
"deprecationMessage": "Deprecated. Use `firstName` and `lastName` instead.",
"description": "Your full name"
}
}
}
In the example above, we’re using strict mode and there’s a nonstandard key called `”deprecationMessage”. It will throw an error with a message like this:
Error: strict mode: unknown keyword: "deprecationMessage"
I would like to see an error message more like this:
Error: strict mode: unknown keyword: "deprecationMessage" at my.schema.json 9:14-9:32