Python 3.x 如何为cerberus添加条件模式
我正在尝试验证模式之一,当请求中不包含random1和random2时,它将给出True。就连我也试过其他的规则。你能帮我吗? 比如,如果我在模式中传递了两个字段,那么它应该传递;如果我在这两个字段中只有一个字段,那么它应该传递;如果我没有传递这两个字段,那么它应该失败Python 3.x 如何为cerberus添加条件模式,python-3.x,jsonschema,cerberus,Python 3.x,Jsonschema,Cerberus,我正在尝试验证模式之一,当请求中不包含random1和random2时,它将给出True。就连我也试过其他的规则。你能帮我吗? 比如,如果我在模式中传递了两个字段,那么它应该传递;如果我在这两个字段中只有一个字段,那么它应该传递;如果我没有传递这两个字段,那么它应该失败 { "offers": { "type": "list", "schema": { "type": "dict", "oneof":[{ "schema": {
{
"offers": {
"type": "list",
"schema": {
"type": "dict",
"oneof":[{
"schema": {
"random1": {
"type": "float",
"empty": False
},
"random2": {
"type": "float",
"empty": False
}}}],
"schema":{
"offerId": {
"type": "string",
"required": True,
"empty": False
},
"frequency": {
"type": "string",
"empty": False
},
"action": {
"type": "string",
"required": True,
"empty": False
}
}
}
}