【发布时间】:2020-03-28 00:33:16
【问题描述】:
我想在我的自定义验证器类中重载验证,这样如果客户端只给我文本,我可以将其转换为 yaml 进行验证。
我尝试了以下方法:
import cerberus
from cerberus import Validator
from ruamel.yaml import YAML
class SchemaValidator(Validator):
def _validate(self, schema_to_check_in_text, schema_from_catalog_in_yaml):
ruamel_yaml = YAML()
parsed_proposed_yaml = ruamel_yaml.load(schema_to_check_in_text)
self.validate(parsed_proposed_yaml, schema_from_catalog_in_yaml)
但它不起作用。这可能吗?
【问题讨论】:
标签: python python-3.x cerberus