Closed
Description
These keywords will complement the existing keyword contains
to define minimum and/or maximum number of items that are valid against the schema in contains
keyword (in the same schema object).
Example:
{
"$comment": "validate that the array contains >= 2 and <= 4 boolean true values",
"type": "array",
"items": {"type": "boolean"},
"contains": {"const": true},
"minContains": 2,
"maxContains": 4
}
Meta-schema:
{
"properties": {
"minContains": {"type": "number", "minimum": 0, "default": 1},
"maxContains": {"type": "number"}
},
"dependencies": {
"minContains": ["contains"],
"maxContains": ["contains"]
}
}
"minContains": 0
would allow limiting the maximum number of matching elements without requiring one matching element.