I have a JSON:
{
"i0": {
"j0": {
"a0": true
}
},
"i1": {
"j1": {
"a1": "stuff"
}
}
}
I want a validation:
If a0
is true, a1
should be required.
My schema is currently:
{
"$schema": "http://json-schema.org/draft-07/schema",
"id": "id",
"type": "object",
"required": [
"i0",
"i1"
],
"allOf": [
{
"if": {
"properties": {
"i0": {
"j0": {
"a0": true
}
}
}
},
"then": {
"properties": {
"i1": {
"j1": {
"required": [
"a1"
]
}
}
}
}
}
]
}
This conditional seems to not actually be run. Alternatively, I have have seen gotten a very similar conditional to work if I try to put the required
on the same level as the value I am checking. As in:
"allOf": [
{
"if": {
"a0": true
},
"then": {
"required": [
"a1"
]
}
}
]
but this would require a1
to be under j0
along with a1
.
How do I require an object under j1
based on a value under j0
?