當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。