How to use the pykwalify.partial_schemas 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 / tests / test_unicode.py View on Github external
def setUp(self):
        pykwalify.partial_schemas = {}
github Grokzen / pykwalify / tests / test_core.py View on Github external
def setUp(self):
        pykwalify.partial_schemas = {}
github Grokzen / pykwalify / tests / test_rule.py View on Github external
def setUp(self):
        pykwalify.partial_schemas = {}
github Grokzen / pykwalify / tests / test_core.py View on Github external
def setUp(self):
        pykwalify.partial_schemas = {}
github Grokzen / pykwalify / pykwalify / core.py View on Github external
def _start_validate(self, value=None):
        """
        """
        path = ""
        self.errors = []
        done = []

        s = {}

        # Look for schema; tags so they can be parsed before the root rule is parsed
        for k, v in self.schema.items():
            if k.startswith("schema;"):
                log.debug(u"Found partial schema; : %s", v)
                r = Rule(schema=v)
                log.debug(u" Partial schema : %s", r)
                pykwalify.partial_schemas[k.split(";", 1)[1]] = r
            else:
                # readd all items that is not schema; so they can be parsed
                s[k] = v

        self.schema = s

        log.debug(u"Building root rule object")
        root_rule = Rule(schema=self.schema)
        self.root_rule = root_rule
        log.debug(u"Done building root rule")
        log.debug(u"Root rule: %s", self.root_rule)

        self._validate(value, root_rule, path, done)
github Grokzen / pykwalify / pykwalify / core.py View on Github external
"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:
                if k == "regex;({})".format(regex_rule.map_regex_rule) or k == "re;({})".format(regex_rule.map_regex_rule):
                    is_regex_rule = True
                    required_regex = regex_rule.map_regex_rule

            # Check for the presense of the required key
            is_present = False
            if not is_regex_rule:
                is_present = k in value