Conditional requirements
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?
Hmm I guess I found the answer. this library is only draft-04 compliant right? Any chance of the library being updated to 07?
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.