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

union types with schemas don't work with :record_errors => true #27

Closed
vapir opened this issue Feb 10, 2012 · 1 comment
Closed

union types with schemas don't work with :record_errors => true #27

vapir opened this issue Feb 10, 2012 · 1 comment

Comments

@vapir
Copy link

vapir commented Feb 10, 2012

union types with schemas work by rescuing ValidationError and continuing to try the next type when one doesn't work.

but ValidationError isn't raised when :record_errors is true, so when the second (or later) union type is the valid one, the error gets added on the first (invalid) union type, and not removed when the valid union type is found.

example with a union type of a schema and 'boolean' follows.

:record_errors is false; works fine:

>> JSON::Validator.validate!({'properties' => {'data' => {'type' => [{'type' => 'object'}, 'boolean']}}}, {'data' => false})
=> true

record_errors is true; reports failure encountered validating the first union type:

>> JSON::Validator.fully_validate({'properties' => {'data' => {'type' => [{'type' => 'object'}, 'boolean']}}}, {'data' => false})
=> ["The property '#/data' of type FalseClass did not match one or more of the following types: object in schema 4e2b2f95-fe4c-5581-b5a7-236873957b50#"]
@hoxworth
Copy link
Contributor

This should be fixed in the latest release, 1.0.4.

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