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

Add in a validation error structure #29

Closed
hoxworth opened this issue Feb 14, 2012 · 5 comments
Closed

Add in a validation error structure #29

hoxworth opened this issue Feb 14, 2012 · 5 comments

Comments

@hoxworth
Copy link
Contributor

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. :)

@obfuscurity
Copy link

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. :)

@hoxworth
Copy link
Contributor Author

Apologizing is what I do best! Just ask my wife!

@obfuscurity
Copy link

I owe you many beers.

@hoxworth
Copy link
Contributor Author

GIVE ME BEERS NOW. Pass a :errors_as_objects option to fully_validate and receive an array of hashes in return.

@obfuscurity
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants