Reputation: 24831
We can enforce empty attribute of type object as follows:
{
"description": "voice mail record",
"type": "object",
"additionalProperties": false,
"properties": {}
}
as explained here.
Now I want to validate attribute which
Enforcing non-emptyness (point 4) is what I am unable to guess. This is somewhat opposite of enforcing emptyness as in above example. My current json schema excerpt looks like this:
"attribute":
{
"type": "object",
"additionalProperties": { "type": ["string","number","integer"] }
}
But above does not enforce non-emptyness. How can I accomplish this?
Upvotes: 9
Views: 4416
Reputation: 12891
Sounds like minProperties
is what you want.
{
"type": "object",
"additionalProperties": {"type": ["string", "number", "integer"]},
"minProperties": 1
}
There is also maxProperties
, which can be used as an alternative solution to the opposite question that you linked to.
Upvotes: 19