문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top