Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seq matching any is over-reporting #125

Closed
StephenEhmann opened this issue Apr 6, 2018 · 2 comments
Closed

seq matching any is over-reporting #125

StephenEhmann opened this issue Apr 6, 2018 · 2 comments

Comments

@StephenEhmann
Copy link

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: '/'>
@J20S
Copy link

J20S commented May 7, 2018

+1

@Grokzen
Copy link
Owner

Grokzen commented May 7, 2018

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.

@Grokzen Grokzen closed this as completed Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants