hoxworth/json-schema — pull request #138 by iainbeeston (2014-10-21 16:15:38+00:00)
Title: Made validation sub errors indicate where they come from

When using anyof or allof in a schema, all of the validation errors for
all of the subschemas are shown in a flat list - all concatenated
together. This makes it very hard (or impossible) to see where in the
schema individual errors come from, and makes it hard to debug the
errors in your json.

This change groups subschema errors together, according to which schema
they appeared under.

The error messages now appear like:

```
The property '#/0' of type Hash did not match one or more of the required schemas. The schema specific errors were:

- subschema #0:
- The property '#/0' did not contain a required property of 'text'
- The property '#/0/type' value "basic_question" did not match one of the following values: text
- The property '#/0' contains additional properties ["title", "required", "number", "identifier"] outside of the schema when none are allowed
- subschema #1:
- The property '#/0/type' value "basic_question" did not match one of the following values: section, subsection
- The property '#/0' contains additional properties ["required", "number", "identifier"] outside of the schema when none are allowed
- subschema #2:
- The property '#/0' did not contain a required property of 'subtitle'
- The property '#/0/type' value "basic_question" did not match one of the following values: repeatable_section
- The property '#/0' contains additional properties ["required", "number", "identifier"] outside of the schema when none are allowed
- subschema #3:
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed
- subschema #4:
- The property '#/0/type' value "basic_question" did not match one of the following values: grouped_question, multi_grouped_question, question_table
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed
- subschema #5:
- The property '#/0/type' value "basic_question" did not match one of the following values: grouped_question, multi_grouped_question, question_table
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed
```

Where before you'd see this:

```
The property '#/0' of type Hash did not match one or more of the required schemas in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
The schema specific errors were:
- The property '#/0' did not contain a required property of 'text' in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0/type' value "basic_question" did not match one of the following values: text in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["title", "required", "number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0/type' value "basic_question" did not match one of the following values: section, subsection in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["required", "number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' did not contain a required property of 'subtitle' in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0/type' value "basic_question" did not match one of the following values: repeatable_section in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["required", "number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0/type' value "basic_question" did not match one of the following values: grouped_question, multi_grouped_question, question_table in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0/type' value "basic_question" did not match one of the following values: grouped_question, multi_grouped_question, question_table in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
- The property '#/0' contains additional properties ["number", "identifier"] outside of the schema when none are allowed in schema 9daf715e-c908-5089-96eb-cd2aa57b05cf#
```