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

regexp error doesn't give as much detail as pattern failure #57

Open
JaredCE opened this issue Feb 22, 2018 · 1 comment
Open

regexp error doesn't give as much detail as pattern failure #57

JaredCE opened this issue Feb 22, 2018 · 1 comment

Comments

@JaredCE
Copy link

JaredCE commented Feb 22, 2018

When I use "pattern" as one of my schema verification properties and AJV finds an error based on the pattern, it'll return an error like:

{ keyword: 'pattern',
     dataPath: '.title',
     schemaPath: '#/properties/title/allOf/0/pattern',
     params: { pattern: '^((?!abc).)*$' },
     message: 'should match pattern "^((?!abc).)*$"' }

Knowing the information about the pattern that is failing is extremely useful to me, yet when i switch from "pattern" to "regexp" via AJV-Keywords, the error returned isn't quite as useful:

{ keyword: 'regexp',
     dataPath: '.tracks[0].label_copy',
     schemaPath: '#/properties/label_copy/allOf/0/regexp',
     params: { keyword: 'regexp' },
     message: 'should pass "regexp" keyword validation' }

not telling me which regexp has failed (e.g. ^((?!abc).)*$/i), I know that I can derive this from schemaPath, but having it in the message and/or the params would be incredibly useful.

@epoberezkin
Copy link
Member

You can use verbose option - it will include schema in the error. This keyword needs to be improved to report errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants