【发布时间】:2018-09-18 06:51:55
【问题描述】:
我正在使用 python 库 cerberus (http://docs.python-cerberus.org/en/stable/),我想检查 JSON 字段是数字(整数)还是空字符串。
我尝试使用条件:
{"empty": True, "type": "intenger"}
但是当字段为空字符串时,例如:(""),我得到如下错误。
'must be of integer type'
有没有一种使用基本验证规则的方法,因此它还可以检测数字字段中的空字符串?我知道可以通过使用扩展验证函数来完成,但我想暂时避免使用这种解决方案。
【问题讨论】:
标签: python validation cerberus