hoxworth/json-schema — pull request #181 by jjbananas (2014-11-21 15:46:29+00:00)
Title: `oneOf` and `anyOf` errors where default values are present

Using `anyOf` or `oneOf` shouldn’t fill JSON object with defaults of non-matching subschemas.

Prior to this change, a JSON object validating against `anyOf` or `oneOf` would be mutated by each subschema with default values, even if that subschema then failed validation. These new properties would then be present in the JSON for validation against subsequent subschemas.

This pull request makes changes so that:

**On Success**
For `anyOf`, the defaults of the first matching subschema persist after returning from the call to `validate`.
For `oneOf`, the defaults of the only matching subschema persist after returning from the call to `validate`.

(It's not obvious what should happen for `allOf`. So we have not attempted to change behaviour here.)

**On Failure**
We set the JSON data back to the original data.