additionalItems : Schema | Boolean
additionalItems
Schema | BooleanIf items is set to an array of schemas, validation succeeds if each element of the instance not covered by it validates against this schema. If set to false, no additional items are allowed in the array instance.
| Value |
This keyword must be set to a valid JSON Schema
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
|---|---|
| Kind | Applicator |
| Applies To | Array |
| Base Dialect | Draft 4 |
| Changed In | None |
| Introduced In | Draft 3 |
| Vocabulary | Validation |
| Specification | https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.5.3.1 |
| Metaschema | http://json-schema.org/draft-04/schema# |
| Official Tests | draft4/additionalItems.json |
| Default |
{}
|
| Annotation | None |
| Affected By |
|
| Affects | None |
| Also See |
|
The additionalItems
keyword restricts array instance items not described by the sibling
items keyword (when items is in array form), to validate against the
given subschema.
Common Pitfall
This keyword only has an effect when the sibling
items keyword is set to an array of
schemas. If items is not present or
is set to a schema (not an array of schemas), additionalItems has no effect and is
ignored.
Common Pitfall
This keyword does not prevent an array instance from being
empty or having fewer items than the items array. If needed, use the minItems keyword to assert on the minimum bounds of the
array.
Remember that JSON Schema is a constraint-driven language.
Therefore, non-array instances successfully validate against this
keyword. If needed, make use of the type keyword to constraint
the accepted type accordingly.
Examples
{
"$schema": "http://json-schema.org/draft-04/schema#",
"items": [ { "type": "boolean" }, { "type": "number" } ],
"additionalItems": { "type": "string" }
}[ false, 35 ][ false, 35, "foo", "bar" ][ false, 35, { "foo": "bar" } ][]"Hello World"{
"$schema": "http://json-schema.org/draft-04/schema#",
"items": [ { "type": "boolean" }, { "type": "number" } ],
"additionalItems": false
}[ false, 35 ][ false, 35, "foo" ]{
"$schema": "http://json-schema.org/draft-04/schema#",
"items": { "type": "number" },
"additionalItems": { "type": "string" }
}[ 1, 2, 3 ][ 1, 2, "foo" ]{
"$schema": "http://json-schema.org/draft-04/schema#",
"additionalItems": { "type": "string" }
}[ 1, 2, 3 ]"Hello World"