I want to do something fairly simple. I've browsed through the questions already asked here but couldn't find an answer to my specific issue. I've played around with excludes
and allowed
and dependencies
, to no avail. Can someone please put me on the right track?
Here's what I'm trying to do:
I have data that looks like {"field1": 1, "field2": true}
. I want to allow field2
to be true
only if field1
is equal to 1
.
Here are a few examples:
Not allowed:
{"field1": 2, "field2" true}
Allowed:
{"field1": 2, "field2" false}
{"field1": 1, "field2": true}
I've tried the following but this doesn't catch the example that is not allowed from above.
'field1': {
'type': 'integer',
'default': 1,
},
'field2': {
'type': 'boolean',
'default': False,
'oneof': [{'excludes': 'field1', 'allowed': [1]}, {'allowed': [True]}]
}