The json schema proposal includes two validations for the properties: minProperties and maxProperties. Using these validations we could define an object with several optional properties and, for example, define that it could have only one property.
until the mess that is json-schema calms down i'm not interested in implementing more of these features, if you have a need though feel free to submit a pull request with tests
The json schema proposal includes two validations for the properties: minProperties and maxProperties. Using these validations we could define an object with several optional properties and, for example, define that it could have only one property.
A example of use is:
schema = {"type": "object", "properties": { "a": {"type":...}, "b": {"type":...}, "minProperties" = 1, "maxProperties" = 1}}
valid: {"a": ...} {"b": ...}
Invalid: {} {"a": ..., "b":...}