Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.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 字典验证Cerberus使用保留关键字_Python_Validation_Cerberus - Fatal编程技术网

Python 字典验证Cerberus使用保留关键字

Python 字典验证Cerberus使用保留关键字,python,validation,cerberus,Python,Validation,Cerberus,我有一个python字典,我正试图使用cerberus验证它。但是,我的dict中的一个字段名为“type”,它与cerberus解析器保留的关键字“type”冲突 有没有什么方法可以绕过这个问题而不必改变原来的字典 有问题的部分 { { ... "db": { "type": "AzureTables", ... } }

我有一个python字典,我正试图使用cerberus验证它。但是,我的dict中的一个字段名为
“type”
,它与cerberus解析器保留的关键字
“type”
冲突

有没有什么方法可以绕过这个问题而不必改变原来的字典

有问题的部分

    {
        {
            ...
            "db": {
                "type": "AzureTables",
                ...
            }
        }
    }

因此,在没有看到您使用的模式的情况下,我在这里进行了一个有根据的猜测

schema = {
'db': {'type': 'dict',
       'schema': {
            'type': {'type': 'string'},
            'some_field': {'type': 'integer'}

       }
      }
}

document = {
      'db': {'type': 'AzureTables',
             'some_field': 5}
}
上面的模式验证后面的文档,没有错误。我猜您缺少了
模式
规则。Cerberus将允许您使用保留的字典键,如果您将这些键放入
模式
规则中,如上所示