Constraint to verify elements of an array based on elements of second array, correclated by index of elements #604
-
I know its not a very well phrased title, hope the write up below will make more sense. Hello Experts,
My requirement is that if value of controlKey is 0 then "maxProperties" of impactedKey should be 0. If if value of controlKey is 1 then "maxProperties" of impactedKey should be 1. But the catch is that effect of each controlKey should be limited to the span of masterArray element that it belongs to. i.e
(Hope I am making sense} In my schema, I setup a {0,1} enum for controlKey and include following If-then-else but it does not seem to work. Basically what seems to be happening the "if" evaluation is happening across all controlKey values in the array and "then" and "else" enforcement is happening across all impactedKeys. Any solution to this? NB: the index keys in the sample above can not be used to formulate the constraints as they do exists in the real json. I included them in sample to be able to explain my problem.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You just need to move your {
"type": "object",
"properties": {
"masterArray": {
"type": "array",
"items": {
"type": "object",
"properties": { ... },
"$comment": "Your conditional would go at this level",
"if": { ... },
"then": { ... }
}
}
}
} |
Beta Was this translation helpful? Give feedback.
You just need to move your
if
/then
to the level of the "masterArray"items
.