ajv-keywords
ajv-keywords copied to clipboard
regexp error doesn't give as much detail as pattern failure
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.
You can use verbose option - it will include schema in the error. This keyword needs to be improved to report errors.