Determining what schema an array element should validate against - sgpinkus/json-schema GitHub Wiki
THIS WIKI IS OBSOLETE. PLEASE SEE THE NEW JSON-SCHEMA-ORG/JSON-SCHEMA-SPEC REPOSITORY.
NOTE: This algorithm was included in Draft 04. Adding the more verbose wording to the web site is tracked at https://github.com/json-schema-org/json-schema-org.github.io/issues/25
For one array element, the schema which this element must validate against depends on its index in the array and the following keywords:
- items,
- additionalItems.
NOTE: array indices start at 0.
If items is absent, its default value is the empty schema. Which means all elements are valid. The end ;)
In this case, all elements of the array instance MUST be valid against the items keyword value, which is a JSON Schema.
If this is an array, then the schema is determined by the index of the array element to validate. There are two possibilities:
In this case, the element MUST be valid against the schema found at the given index in the items array.
In this case, it depends on the value of additionalItems:
This is equivalent to additionalItems being an empty schema, which means the element always validates successfully.
If it is an object, then by the rules, it is a valid JSON Schema. In this case, the element MUST validate successfully against that schema.