-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Add in a validation error structure #29
Comments
Dude you don't have to apologize to anyone for giving up your spare time working on open-source software. I just appreciate you humoring me. :) |
Apologizing is what I do best! Just ask my wife! |
I owe you many beers. |
GIVE ME BEERS NOW. Pass a :errors_as_objects option to fully_validate and receive an array of hashes in return. |
You're a rock star. Beers have been duly earned. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From @obfuscurity (yes, I'll actually do this instead of ignore it for another month):
How difficult would it be to pass back an AoH with the property
attribute? For example, instead of:
[6] pry(main)>
JSON::Validator.fully_validate('{"name":"User","properties":{"firstname":{"description":"Name","type":"string","minLength":1,"required":true},"lastname":{"description":"Surname","type":"string","minLength":1,"required":false}}}', '{"firstname":""}', :validate_schema => true)
=> ["The property '#/firstname' was not of a minimum string length of 1 in schema 57060c97-bfe0-5cfd-a710-1b7f675d98e7#"]
You get:
=>
[
{
:property => 'firstname',
:failed_attribute => 'minLength',
:message => "The property '#/firstname' was not of a minimum string length of 1 in schema 57060c97-bfe0-5cfd-a710-1b7f675d98e7#"
}
]
It's not a huge deal, but it could be very useful. Assuming the format
is static I can just regex it out. Either way thank you for this
feature. :)
The text was updated successfully, but these errors were encountered: