I would like to validate a JSON schema (as shown below). In the schema below what I tried for required is not correct. I need to validate schema in two ways as below:
Object1_Property1
is exist in Object1
, then Object2
is required, else not required.Object1_Property1
of Object1
is "Result", then Object2
is required, else not required.Could you please help with this?
{
"$schema": "http://json-schema.org/draft-04/schema",
"title": "Company-name",
"type": "object",
"additionalProperties": false,
"properties": {
"Object1": {
"additionalProperties": false,
"properties": {
"Object1_Property1": {
"type": "string"
},
"Object1_Property2": {
"type": "string"
}
},
"required": ["Object1_Property1", "Object1_Property2"]
},
"Object2": {
"description": "xyz",
"type": "object",
"properties": {
"Object2_Property1": {
"type": "string"
},
"Object2_Property2": {
"type": "string"
}
},
"required": ["Object2_Property1", "Object2_Property2"]
}
},
"required": ["Object1", "Object2"]
}