Reputation: 4013
Is it possible to verify a JSON schema using AND conditions between two elements?
I have an example where I need to verify property A only if property B has value "true". for example:
{
"A":"verify me only if B is true",
"B": "false"
}
in this case, A should not be verified at all.
I can verify A or B separately but don't know how to link the two.
Thanks!
Upvotes: 3
Views: 336
Reputation: 52538
You create two alternatives using anyOf.
In the first alternative, B is an enumeration with just the value true, A is verified, and presumably you want both A and B required. In the second alternative, B is not (an enumeration with just the value true), and A is not verified.
Upvotes: 3