hoxworth/json-schema — Issue #27: union types with schemas don't work with :record_errors => true 
Author: vapir
Created: 2012-02-10 07:04:12+00:00
State: open

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:

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

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

```ruby
>> 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#"]
```