How to use the pykwalify.partial_schemas.get function in pykwalify

To help you get started, we’ve selected a few pykwalify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Grokzen / pykwalify / pykwalify / core.py View on Github external
self._validate_range(
                r.get("max"),
                r.get("min"),
                r.get("max-ex"),
                r.get("min-ex"),
                len(value),
                path,
                "map",
            )

        for k, rr in m.items():
            # Handle if the value of the key contains a include keyword
            if rr.include_name is not None:
                include_name = rr.include_name
                partial_schema_rule = pykwalify.partial_schemas.get(include_name)

                if not partial_schema_rule:
                    self.errors.append(SchemaError.SchemaErrorEntry(
                        msg=u"Cannot find partial schema with name '{include_name}'. Existing partial schemas: '{existing_schemas}'. Path: '{path}'",
                        path=path,
                        value=value,
                        include_name=include_name,
                        existing_schemas=", ".join(sorted(pykwalify.partial_schemas.keys()))))
                    return

                rr = partial_schema_rule

            # Find out if this is a regex rule
            is_regex_rule = False
            required_regex = ""
            for regex_rule in rule.regex_mappings:
github Grokzen / pykwalify / pykwalify / core.py View on Github external
def _validate_include(self, value, rule, path, done=None):
        """
        """
        # TODO: It is difficult to get a good test case to trigger this if case
        if rule.include_name is None:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u'Include name not valid',
                path=path,
                value=value.encode('unicode_escape')))
            return
        include_name = rule.include_name
        partial_schema_rule = pykwalify.partial_schemas.get(include_name)
        if not partial_schema_rule:
            self.errors.append(SchemaError.SchemaErrorEntry(
                msg=u"Cannot find partial schema with name '{include_name}'. Existing partial schemas: '{existing_schemas}'. Path: '{path}'",
                path=path,
                value=value,
                include_name=include_name,
                existing_schemas=", ".join(sorted(pykwalify.partial_schemas.keys()))))
            return

        self._validate(value, partial_schema_rule, path, done)