【发布时间】:2022-02-17 13:19:12
【问题描述】:
我想在 Cerberus 的 datetime 类型中验证一个值大于或等于 01/01/1900 的字段,但不能以这种方式工作:
from cerberus import Validator
from datetime import datetime
v = Validator()
schema = {
"birthdate": {
"type": "datetime",
"required": True,
"min": datetime(1900, 1, 1)
}
}
document_valid = {'birthdate': '05/03/1900'}
document_invalid = {'birthdate': '05/03/1800'}
print(v.validate(document_valid, schema)) # I want this True
print(v.validate(document_invalid, schema)) # I want this False
谁能帮帮我?
我在 Cerberus 上使用这个版本:Cerberus==1.3.4
【问题讨论】:
标签: python date datetime validation cerberus