Closed
Description
Given the following schema:
{
"type": "object",
"required": [
"numberOfModules"
],
"properties": {
"numberOfModules": {
"allOf": [
{
"not": {
"type": "integer",
"minimum": 38
}
},
{
"not": {
"type": "integer",
"maximum": 37,
"minimum": 25
}
},
{
"not": {
"type": "integer",
"maximum": 24,
"minimum": 12
}
}
]
}
}
}
When I validate, I get a high level error description saying allOf
failed:
2.3.3 :009 > schemer.validate({ 'numberOfModules' => 32 }).to_a
=> [{"data"=>21, "schema"=>{"x-notification"=>"Reduce system size - Deselect modules to reduce the cost of a main service panel upgrade.", "allOf"=>[{"not"=>{"x-cost"=>7500, "type"=>"integer", "minimum"=>38}}, {"not"=>{"x-cost"=>5000, "type"=>"integer", "maximum"=>37, "minimum"=>25}}, {"not"=>{"x-cost"=>2500, "type"=>"integer", "maximum"=>24, "minimum"=>12}}, {"x-error"=>"Number of modules cannot be negative.", "type"=>"integer", "minimum"=>0}]}, "pointer"=>"/numberOfModules", "type"=>"allOf"}]
https://ajv.js.org/ gives a more specific error path:
> ajv.validate(s.design, { numberOfModules: 32 })
false
> ajv.errors
[ { keyword: 'maximum',
dataPath: '.numberOfModules',
schemaPath: '#/properties/numberOfModules/then/then/else/maximum',
params: { comparison: '<=', limit: 24, exclusive: false },
message: 'should be <= 24' } ]
It's nice to have the schema path for the lowest level of failure. I'm potentially open to working on a PR, but first wanted to know your thoughts on whether:
- You are open to moving in this direction.
- Moving in this direction would open up a whole can of worms that would require a large effort. For instance, if we made error paths more precise of
allOf
- would we then need to work on that foranyOf
,oneOf
,if
,then
, etc - or could we add these piecemeal?
Metadata
Metadata
Assignees
Labels
No labels