JVal icon indicating copy to clipboard operation
JVal copied to clipboard

Conditional requirements

Open jegjessing opened this issue 6 years ago • 2 comments

Hi, I have tried to add an "if", "then", "else" in my schema, to add conditional required fields but I cannot make it work :-( Using the validator I get a validation error (as expected) if I use the following: "required": [ "transactionIdentifier", "reasonCode", "meteringpointId", "contractEnd" ]

but if I change this to: "required": [ "transactionIdentifier", "reasonCode", "meteringpointId" ], "if": {"properties": {"header": {"properties": {"messageType": {"const": "406"}}}}}, "then": {"required": ["contractEnd"]}, "else": {"required": ["contractEnd"]} I would expect the same result, since I have the same resulting "required" no matter what the condition.. But no, the field is not required...

So my question is, since "if" cases are not included in your Data folder. It is not implemented?

jegjessing avatar Jan 03 '19 12:01 jegjessing

Hmm I guess I found the answer. this library is only draft-04 compliant right? Any chance of the library being updated to 07?

jegjessing avatar Jan 03 '19 12:01 jegjessing

Hi. Indeed, this is a 04-only lib for now. I'd like to catch up with the spec at some point, but by lack of time, it probably won't happen in the immediate future.

stefk avatar Jan 03 '19 16:01 stefk