本文整理汇总了Python中jsonschema._utils.types_msg方法的典型用法代码示例。如果您正苦于以下问题:Python _utils.types_msg方法的具体用法?Python _utils.types_msg怎么用?Python _utils.types_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonschema._utils
的用法示例。
在下文中一共展示了_utils.types_msg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: type_draft3
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import types_msg [as 别名]
def type_draft3(validator, types, instance, schema):
types = _utils.ensure_list(types)
all_errors = []
for index, type in enumerate(types):
if type == "any":
return
if validator.is_type(type, "object"):
errors = list(validator.descend(instance, type, schema_path=index))
if not errors:
return
all_errors.extend(errors)
else:
if validator.is_type(instance, type):
return
else:
yield ValidationError(
_utils.types_msg(instance, types), context=all_errors,
)
示例2: type_draft3
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import types_msg [as 别名]
def type_draft3(validator, types, instance, schema):
types = _utils.ensure_list(types)
# NOTE(kiall): A datetime object is not a string, but is still valid.
if ('format' in schema and schema['format'] == 'date-time' and
isinstance(instance, datetime.datetime)):
return
all_errors = []
for index, type in enumerate(types):
if type == "any":
return
if validator.is_type(type, "object"):
errors = list(validator.descend(instance, type, schema_path=index))
if not errors:
return
all_errors.extend(errors)
else:
if validator.is_type(instance, type):
return
else:
yield jsonschema.ValidationError(
_utils.types_msg(instance, types), context=all_errors,
)
示例3: type_draft4
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import types_msg [as 别名]
def type_draft4(validator, types, instance, schema):
types = _utils.ensure_list(types)
if not any(validator.is_type(instance, type) for type in types):
yield ValidationError(_utils.types_msg(instance, types))
示例4: type_draft4
# 需要导入模块: from jsonschema import _utils [as 别名]
# 或者: from jsonschema._utils import types_msg [as 别名]
def type_draft4(validator, types, instance, schema):
types = _utils.ensure_list(types)
# NOTE(kiall): A datetime object is not a string, but is still valid.
if ('format' in schema and schema['format'] == 'date-time' and
isinstance(instance, datetime.datetime)):
return
if not any(validator.is_type(instance, type) for type in types):
yield jsonschema.ValidationError(_utils.types_msg(instance, types))