-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Schema validator #52
base: os-17/json-schema-validation
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine 👍
Can you remove active_model from dev_deps ?
And upgrade schema to v7 + schemer upgrade (as discussion in target PR)
http://json-schema.org/specification-links.html#draft-7
errors = [] | ||
|
||
schema.validate(payload).each do |validation_error| | ||
errors << nice_error(validation_error) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors = [] | |
schema.validate(payload).each do |validation_error| | |
errors << nice_error(validation_error) | |
end | |
errors = schema.validate(payload).map do |validation_error| | |
nice_error(validation_error) | |
end |
I already removed my previous comment; I didn't realize it was actually a request to merge into target PR. |
About Try that, maybe that will resolve the issue. |
unless schema.valid?(payload) # rubocop:disable Style/GuardClause | ||
errors = [] | ||
|
||
schema.validate(payload).each do |validation_error| | ||
errors << nice_error(validation_error) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schemer seems not caching validation result so:
unless schema.valid?(payload) # rubocop:disable Style/GuardClause | |
errors = [] | |
schema.validate(payload).each do |validation_error| | |
errors << nice_error(validation_error) | |
end | |
validation_errors = schema.validate(payload) | |
unless validation_errors.blank? # rubocop:disable Style/GuardClause | |
errors = validation_errors.map do |validation_error| | |
nice_error(validation_error) | |
end |
Proposed change to not use ActiveModel::Validations.
TODO: