Draft 04 | Draft 06 | Draft 07 | Draft 2019-09 | Draft 2020-12 |
![]() |
![]() |
![]() |
![]() |
![]() |
A property dependency has a name and a list of 1 or more property names.
If the named property exists, then the list of named properties must also exist.
Example |
Copy Code
|
---|---|
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "title": "My schema", "additionalProperties": false, "properties": { "Price": { "type": "number" }, "Currency": { "type": "string" } }, "dependencies": { "Currency": [ "Price" ] } } |
In this example if the property 'Currency' is present then the 'Price' property must also be present.
The converse is NOT true, 'Price' can be present without 'Currency', in order to ensure they both exist or neither exists, a second property dependency would have to be added saying id 'Price' exists 'Currency' must exist.