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


Python validators.validator_for方法代码示例

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


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

示例1: getValidator

# 需要导入模块: from jsonschema import validators [as 别名]
# 或者: from jsonschema.validators import validator_for [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: full_validate

# 需要导入模块: from jsonschema import validators [as 别名]
# 或者: from jsonschema.validators import validator_for [as 别名]
def full_validate(
    schema: RawSchema, raw_items: RawItems, keys: pd.Index
) -> Dict[str, set]:
    """This function uses jsonschema validator which returns all found error per item.
    See `fast_validate()` for arguments descriptions.
    """
    errors: DefaultDict = defaultdict(set)

    validator = validators.validator_for(schema)(schema)
    validator.format_checker = FormatChecker()
    for i, raw_item in enumerate(tqdm(raw_items, desc="JSON Schema Validation")):
        raw_item.pop("_type", None)
        raw_item.pop("_key", None)
        for e in validator.iter_errors(raw_item):
            error = format_validation_message(
                e.message, e.path, e.schema_path, e.validator
            )
            errors[error].add(keys[i])
    return dict(errors) 
开发者ID:scrapinghub,项目名称:arche,代码行数:21,代码来源:schema.py

示例3: parse_args

# 需要导入模块: from jsonschema import validators [as 别名]
# 或者: from jsonschema.validators import validator_for [as 别名]
def parse_args(args):
    arguments = vars(parser.parse_args(args=args or ["--help"]))
    if arguments["validator"] is None:
        arguments["validator"] = validator_for(arguments["schema"])
    return arguments 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:cli.py

示例4: _validate

# 需要导入模块: from jsonschema import validators [as 别名]
# 或者: from jsonschema.validators import validator_for [as 别名]
def _validate(self, data, strict=False):
        validator_cls = validator_for(self._schema)
        validator = validator_cls(schema=self._schema, format_checker=format_checker)
        errors = validator.iter_errors(data)

        for error in errors:
            absolute_path = list(error.absolute_path)
            required_match = REQUIRED_RE.search(error.message)
            if required_match:
                absolute_path.append(required_match.group(1))
            field_name = ".".join([str(p) for p in absolute_path])
            self._add_errors({field_name: [error.message]}) 
开发者ID:scrapinghub,项目名称:spidermon,代码行数:14,代码来源:validator.py

示例5: validate

# 需要导入模块: from jsonschema import validators [as 别名]
# 或者: from jsonschema.validators import validator_for [as 别名]
def validate(parsed_data):
        # Load the schema
        schema_file = open(RULES_FILE, 'r')
        schema_data = json.load(schema_file)

        # Validate the file
        validator = validator_for(schema_data)
        errors = validator(schema=schema_data).iter_errors(parsed_data)

        # Extract error messages and return
        messages = []
        for error in errors:
            messages.append('---- ISSUE: ' + error.schema['title'] + '; ' + error.message)
        return messages 
开发者ID:nightwatchcybersecurity,项目名称:truegaze,代码行数:16,代码来源:adobe_mobile_sdk.py


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