minProperties : Integer

minProperties

Integer

An 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.

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

A schema that constrains object instances to define at least 2 properties Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "minProperties": 2
}
Valid An object value with more than 2 properties is valid Instance
{ "foo": 1, "bar": 2, "baz": 3 }
Valid An object value with 2 properties is valid Instance
{ "foo": 1, "bar": 2 }
Invalid An object value with less than 2 properties is invalid Instance
{ "foo": 1 }
Valid A non-object value is valid Instance
"Hello World"