Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何为cerberus添加条件模式_Python 3.x_Jsonschema_Cerberus - Fatal编程技术网

Python 3.x 如何为cerberus添加条件模式

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": {

我正在尝试验证模式之一,当请求中不包含random1和random2时,它将给出True。就连我也试过其他的规则。你能帮我吗? 比如,如果我在模式中传递了两个字段,那么它应该传递;如果我在这两个字段中只有一个字段,那么它应该传递;如果我没有传递这两个字段,那么它应该失败

{
  "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
        }
      }
    }
}