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

Improve type validation #485

Closed
epoberezkin opened this issue May 8, 2017 · 1 comment · Fixed by #488
Closed

Improve type validation #485

epoberezkin opened this issue May 8, 2017 · 1 comment · Fixed by #488

Comments

@epoberezkin
Copy link
Member

epoberezkin commented May 8, 2017

Problem

  1. Duplicate validation of type for type integer.
  2. If there is no type-specific keyword for (one of) required type(s), these types are validated after all keywords.

Both inefficiencies prevent implementing ajv-keywords #100: errorMessage keyword does not catch type errors when type is validated after all keywords.

Solution

  1. Schema {type: 'integer', minimum: 1, maximum: 5} is currently compiled to:
if data is a number, check that it is >= 1 and <=5, otherwise check that it is an integer.

Instead it should be compiled to:

if data is an integer, check that it is >= 1 and <=5, otherwise fail validation.
  1. Validate all types for which there are no keywords before all keywords.
@epoberezkin
Copy link
Member Author

change for integer is reverted so that schema {type: 'integer', maximum: 5} returns 2 errors for 5.5.

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

Successfully merging a pull request may close this issue.

1 participant