当前位置: 首页>>代码示例>>Python>>正文


Python jsonschema.draft4_format_checker方法代码示例

本文整理汇总了Python中jsonschema.draft4_format_checker方法的典型用法代码示例。如果您正苦于以下问题:Python jsonschema.draft4_format_checker方法的具体用法?Python jsonschema.draft4_format_checker怎么用?Python jsonschema.draft4_format_checker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jsonschema的用法示例。


在下文中一共展示了jsonschema.draft4_format_checker方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getValidator

# 需要导入模块: import jsonschema [as 别名]
# 或者: from jsonschema import draft4_format_checker [as 别名]
def getValidator(schema, schema_store):
    """
    Get a L{jsonschema} validator for C{schema}.

    @param schema: The JSON Schema to validate against.
    @type schema: L{dict}

    @param dict schema_store: A mapping between schema paths
        (e.g. ``b/v1/types.json``) and the JSON schema structure.
    """
    # The base_uri here isn't correct for the schema,
    # but does give proper relative paths.
    resolver = LocalRefResolver(
        base_uri=b'',
        referrer=schema, store=schema_store)
    return validator_for(schema)(
        schema, resolver=resolver, format_checker=draft4_format_checker) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:19,代码来源:_schema.py

示例2: validate

# 需要导入模块: import jsonschema [as 别名]
# 或者: from jsonschema import draft4_format_checker [as 别名]
def validate(data, schema):
    """Validate data against a JSON schema.

    This is a helper function used by :py:class:`JsonSchemaValidationMixin`
    to validate data against a JSON schema. If validation fails this function
    will raise a :py:class:`pyramid.httpexceptions.HTTPBadRequest` exception
    describing the validation error.

    :raises pyramid.httpexceptions.HTTPBadRequest: if validation fails this
        exception is raised to abort any further processing.
    """
    try:
        jsonschema.validate(data, schema,
            format_checker=jsonschema.draft4_format_checker)
    except jsonschema.ValidationError as e:
        error = {
            '.'.join(str(p) for p in e.path): e.message
        }
        response = JSONValidationError(json=error)
        response.validation_error = e
        raise response 
开发者ID:wichert,项目名称:rest_toolkit,代码行数:23,代码来源:jsonschema.py

示例3: validate

# 需要导入模块: import jsonschema [as 别名]
# 或者: from jsonschema import draft4_format_checker [as 别名]
def validate(self):
        try:
            Draft4Validator(self.schema, format_checker=draft4_format_checker).validate(
                self.config
            )
        except JsonSchemaError as e:
            raise ValidationError(e) 
开发者ID:openwisp,项目名称:netjsonconfig,代码行数:9,代码来源:backend.py

示例4: is_input_valid

# 需要导入模块: import jsonschema [as 别名]
# 或者: from jsonschema import draft4_format_checker [as 别名]
def is_input_valid(self, request, pipeline_config, section):
        config = pipeline_config.get(section, {})
        try:
            if (section in request):
                input_validator = jsonschema.Draft4Validator(
                    schema=config, format_checker=jsonschema.draft4_format_checker)
                input_validator.validate(request.get(section, {}))
                self.logger.debug(
                    "{} Validation successful".format(section))
            return True
        except Exception as error:
            self.logger.debug(
                "Validation error in request section {}, error: {}".format(section, error))
            return False 
开发者ID:intel,项目名称:video-analytics-serving,代码行数:16,代码来源:pipeline_manager.py


注:本文中的jsonschema.draft4_format_checker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。