additionalItems : Schema
additionalItems
SchemaIf items
is set to an array of schemas, validation succeeds if each element of the instance not covered by it validates against this schema.
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 Annotation |
Applies To | Array |
Base Dialect | 2019-09 |
Changed In | None |
Introduced In | Draft 3 |
Vocabulary | Applicator |
Specification | https://json-schema.org/draft/2019-09/draft-handrews-json-schema-02#rfc.section.9.3.1.2 |
Metaschema | https://json-schema.org/draft/2019-09/meta/applicator |
Official Tests | draft2019-09/additionalItems.json |
Default |
{}
|
Annotation |
Boolean
A boolean true if it applied to any item of the instance
Hint: Use the jsonschema validate command to collect annotations from the command-line
|
Affected By |
|
Affects |
|
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. Whether this keyword was evaluated against any item of the
array instance is reported using annotations.
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": "https://json-schema.org/draft/2019-09/schema",
"items": [ { "type": "boolean" }, { "type": "number" } ],
"additionalItems": { "type": "string" }
}
[ false, 35 ]
{ "keyword": "/items", "instance": "", "value": true }
[ false, 35, "foo", "bar" ]
{ "keyword": "/items", "instance": "", "value": 1 }
{ "keyword": "/additionalItems", "instance": "", "value": true }
[ false, 35, { "foo": "bar" } ]
[]
"Hello World"
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [ { "type": "boolean" }, { "type": "number" } ],
"additionalItems": false
}
[ false, 35 ]
{ "keyword": "/items", "instance": "", "value": true }
[ false, 35, "foo" ]
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": { "type": "number" },
"additionalItems": { "type": "string" }
}
[ 1, 2, 3 ]
{ "keyword": "/items", "instance": "", "value": true }
[ 1, 2, "foo" ]
{ "keyword": "/items", "instance": "", "value": true }
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"additionalItems": { "type": "string" }
}
[ 1, 2, 3 ]
"Hello World"