seq matching any is over-reporting
StephenEhmann opened this issue · comments
schema:
matching: 'any'
seq:
- map:
name:
required: True
type: str
pattern: \S+
min:
required: True
type: number
max:
required: True
type: number
step:
required: True
type: number
setValue:
required: True
type: str
- map:
name:
required: True
type: str
pattern: \S+
enum:
required: True
seq:
- type: text
setValue:
required: True
type: str
data that passes validation:
- name: A
min: 0
max: 2
step: 1
setValue: touch A.$value
data that fails validation (only remove the required "name" field):
- min: 0
max: 2
step: 1
setValue: touch A.$value
I get this error report:
--- All found errors ---
["Cannot find required key 'name'. Path: '/0'", "Cannot find required key 'name'. Path: '/0'", "Cannot find required key 'enum'. Path: '/0'", "Key 'min' was not defined. Path: '/0'", "Key 'max' was not defined. Path: '/0'", "Key 'step' was not defined. Path: '/0'"]
<SchemaError: error code 2: Schema validation failed:
- Cannot find required key 'name'. Path: '/0'.
- Cannot find required key 'name'. Path: '/0'.
- Cannot find required key 'enum'. Path: '/0'.
- Key 'min' was not defined. Path: '/0'.
- Key 'max' was not defined. Path: '/0'.
- Key 'step' was not defined. Path: '/0'.: Path: '/'>
In this case it is reporting all validation failures of the seq item against the both choices of schema for a seq item. An improvement to only print the errors for the choice of schema for which there were the minimum number of failures which would yield this:
--- All found errors ---
["Cannot find required key 'name'. Path: '/0'"]
<SchemaError: error code 2: Schema validation failed:
- Key 'step' was not defined. Path: '/0'.: Path: '/'>
+1
Interesting case indeed. I am not sure if i want to track all suberrors and silence the errors to the path that has the least number of errors.
But what i do think is that the error is that it probably should say the following
Cannot find required key 'name'. Path: '/0'.
Cannot find required key 'name'. Path: '/1'.
Cannot find required key 'enum'. Path: '/1'.
Key 'min' was not defined. Path: '/1'.
Key 'max' was not defined. Path: '/1'.
Key 'step' was not defined. Path: '/1'.: Path: '/'>
This would indicate what path that created what errors becuase that is what the path key is used for.