minProperties : Integer
minProperties
IntegerAn object instance is valid if its number of properties is greater than, or equal to, the value of this keyword.
Value | This keyword must be set to a zero or positive integer |
---|---|
Kind | Assertion |
Applies To | Object |
Base Dialect | 2020-12 |
Changed In | None |
Introduced In | Draft 4 |
Vocabulary | Validation |
Specification | https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.5.2 |
Metaschema | https://json-schema.org/draft/2020-12/meta/validation |
Official Tests | draft2020-12/minProperties.json |
Default |
0
|
Annotation | None |
Affected By | None |
Affects | None |
Also See |
|
The minProperties
keyword restricts object instances to consists of an
inclusive minimum numbers of properties.
Common Pitfall
The presence of this keyword does not depend on the presence of the
properties
keyword.
Remember that JSON Schema is a constraint-driven language.
Therefore, non-object 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/2020-12/schema",
"minProperties": 2
}
{ "foo": 1, "bar": 2, "baz": 3 }
{ "foo": 1, "bar": 2 }
{ "foo": 1 }
"Hello World"