Example #1
0
    def __call__(self, data, tree):
        """
        Go through each item in data against the first schema in the arguments.
        If that fails try each subsequent schema until it passes. Even if
        schemas are failing to apply to that given item, consume all the
        available ones until at least one passes.

        If nothing passes, the last error is raised.

        :param data: Incoming data from the validator engine in normalized dict
        form.
        :param tree: The traversing tree up to this point, always passed in.
        :raises Invalid: If none of the schemas can validate the data.
        """
        first_schema = expand_schema(self.schemas[0])
        index = len(data) - 1
        validator = RecursiveValidator(data, first_schema, [], index=index)
        for item_index in range(len(data)):
            try:
                validator.leaf(item_index)
            except Invalid:
                self.itemized_validation(validator, item_index)
Example #2
0
    def __call__(self, data, tree):
        index = len(data) - 1
        validator = RecursiveValidator(data, self.schema, [], index=index)
        for item_index in range(len(data)):
            try:
                return validator.leaf(item_index)
            except Invalid:
                if tree:
                    tree.pop
                pass

        msg = "did not contain any valid objects against callable: %s" % self.__class__.__name__
        raise Invalid(self.schema, tree, pair='value', msg=msg)
Example #3
0
    def __call__(self, data, tree):
        schema = expand_schema(self.schema)
        index = len(data) - 1
        validator = RecursiveValidator(data, schema, [], index=index)
        for item_index in range(len(data)):
            try:
                return validator.leaf(item_index)
            except Invalid:
                if tree:
                    tree.pop
                pass

        msg = "did not contain any valid objects against callable: %s" % self.__class__.__name__
        raise Invalid(schema, tree, pair='value', msg=msg)