maxItems : Integer
maxItems
IntegerAn array instance is valid if its size is less than, or equal to, the value of this keyword.
| Value |
This keyword must be set to a zero or positive integer
Hint: Use the jsonschema metaschema and jsonschema lint commands to catch keywords set to invalid values
|
|---|---|
| Kind | Assertion |
| Applies To | Array |
| Base Dialect | Draft 4 |
| Changed In | None |
| Introduced In | Draft 1 |
| Vocabulary | Validation |
| Specification | https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.5.3.2 |
| Metaschema | http://json-schema.org/draft-04/schema# |
| Official Tests | draft4/maxItems.json |
| Default | None |
| Annotation | None |
| Affected By | None |
| Affects | None |
| Also See |
|
The maxItems keyword restricts array instances to consists of an inclusive
maximum numbers of items.
Best Practice
To restrict array instances to the empty array, prefer using
the enum keyword with a single empty
array value instead of setting this keyword to 0.
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#",
"maxItems": 3
}[ 1, 2, 3, 4 ][ 1, true, "hello" ][ false, "foo" ]"Hello World"