ajv-keywords
ajv-keywords copied to clipboard
`select` errors have no `dataPath`
TypeScript input:
import * as Ajv from 'ajv';
import * as AjvKeywords from 'ajv-keywords';
const ajv = new Ajv({
$data: true,
messages: true,
verbose: true,
allErrors: true
});
AjvKeywords(ajv);
const schema = {
type: 'object',
properties: {
Fee: {
select: { $data: '1/Type' },
selectCases: {
TYPE1: { maximum: 100 },
TYPE2: { maximum: 200 }
},
type: 'number'
},
Type: {
type: 'string'
}
}
};
const validate = ajv.compile(schema);
const valid = validate({
Type: 'TYPE1',
Fee: 150
});
if (!valid) {
console.log(validate.errors);
}
Output:
[ { keyword: 'maximum',
dataPath: '',
schemaPath: '#/properties/Fee/select',
params: { comparison: '<=', limit: 100, exclusive: undefined },
message: 'should be <= 100',
schema: 'TYPE1',
parentSchema: { maximum: 100 },
data: 150 } ]
I would expect dataPath to be .Fee but it's empty.
"dependencies": {
"ajv": "^5.0.4-beta",
"ajv-keywords": "2.0.1-beta.2"
}
https://runkit.com/esp/58f244ff90f8c30014c36698
Same goes for "deepRequired" it seems..
Hello, I think https://github.com/ajv-validator/ajv-keywords/pull/54#issuecomment-685903741 is related to this issue. Please let me know if I am mistaken and I will delete this comment.
Thank you !
Per the README, select is deprecated. I doubt this will be fixed. As the author of the issue, I'm closing it.