You need to declare a rule at the schema level that defines the object that contains these two properties. You can then use the dependentSchemas, dependentRequired, or if/then/else keywords to define rules like "if <something> in property A, then <something> in property B".
https://json-schema.org/understanding-json-schema/reference/conditionals.html
For example:
{
"type": "object",
"properties": {
"A": {
"type": "object",
"properties":{ "X":{"type":"boolean"}}
},
"B": {
"type": "object",
"properties":{...}
}
},
"if": {
"required": ["A"],
"properties": {
"A": {
"required": ["X"],
"properties": { "X": { "const": true } }
}
}
},
"then": {
"required": ["B"],
"properties": {
"B": {
"required": ["Y"],
"properties": { "Y": { "const": "/A/X is true" } }
}
}
}
}
This is saying "if property A exists, and has a subproperty X which is true, then there must be a property Y under B which is the string "/A/X is true"".