Attempt multiple validators on an object.

    - If any pass, then all validation passes.
    - Otherwise, raise all of the errors.
167587
def any_validator(obj, validators, **kwargs):
    
    if not len(validators) > 1:
        raise ValueError(
            "any_validator requires at least 2 validator.  Only got "
            "{0}".format(len(validators))
        )
    errors = ErrorDict()
    for key, validator in validators.items():
        try:
            validator(obj, **kwargs)
        except ValidationError as err:
            errors[key] = err.detail
        else:
            break
    else:
        if len(errors) == 1:
            # Special case for a single error.  Just raise it as if it was the
            # only validator run.
            error = errors.values()[0]
            raise ValidationError(error)
        else:
            # Raise all of the errors with the key namespaces.
            errors.raise_()
837395
def validate(self, value):
        
        errors = []
        value = self._validate_type(value, errors)
        self._validate_value(value, errors)

        if errors:
            raise ValidationErrors(errors)

        return value
117483
function validator(value, next) {
    validationErrors = [];
    var isValid = true;

    validatorsArray.forEach(function(validator) {
      validator.validator.call(this, value, function(valid) {
        if (!valid) {
          // Append message
          validationErrors.push(validator.message);

          isValid = false;
        }
      });
    }.bind(this));
    return next(isValid);
  }
361850
def validate(self, *args, **kwargs):
        
        # Schemes validation interface
        if is_scheme(self.validator):
            params = getcallargs(self.function, *args, **kwargs)
            params.update(kwargs)
            validator = self.validator(data=params, request=None)
            if validator.is_valid():
                return
            raise self.exception(validator.errors)

        # Simple validation interface
        if hasattr(self.validator, 'is_valid'):
            validator = self.validator(*args, **kwargs)
            # is valid
            if validator.is_valid():
                return
            # is invalid
            if hasattr(validator, 'errors'):
                raise self.exception(validator.errors)
            if hasattr(validator, '_errors'):
                raise self.exception(validator._errors)
            raise self.exception

        validation_result = self.validator(*args, **kwargs)
        # is invalid (validator return error message)
        if isinstance(validation_result, string_types):
            raise self.exception(validation_result)
        # is valid (truely result)
        if validation_result:
            return
        # is invalid (falsy result)
        raise self.exception
547546
def validate(self, data):
        '''
        '''
        try:
            self._validator.validate(data)
        except jsonschema.ValidationError as e:
            six.raise_from(ValidationError.create_from(e), e)
1258346
def validate(self, value):
        
        errors = []

        # Make sure the type validates first.
        valid = self._is_valid(value)
        if not valid:
            errors.append(self.fail(value))
            return errors

        # Then validate all the constraints second.
        for constraint in self._constraints_inst:
            error = constraint.is_valid(value)
            if error:
                errors.append(error)

        return errors
1111910
def fail(self, reason, obj, pointer=None):
        
        pointer = pointer_join(pointer)
        err = ValidationError(reason, obj, pointer)
        if self.fail_fast:
            raise err
        else:
            self.errors.append(err)
        return err
1162038
def validate(self):
        
        validator = Draft7Validator(self.SCHEMA)

        errors = set()  # make errors a set to avoid duplicates

        for error in validator.iter_errors(self.serialize()):
            errors.add('.'.join(
                list(map(str, error.path)) + [error.message]
            ))

        if errors:
            raise JSONValidationException(type(self).__name__, errors)
1308863
def validate(self, value):
        
        errors = []
        self._used_validator = []
        for val in self._validators:
            try:
                val.validate(value)
                self._used_validator.append(val)
            except ValidatorException as e:
                errors.append(e)
            except Exception as e:
                errors.append(ValidatorException("Unknown Error", e))
        if len(errors) > 0:
            raise ValidatorException.from_list(errors)
        return value
390612
def validate(self, value):
        
        for validator in self.validators:
            errors = []
            try:
                validator(value)
            except ValidationError as err:
                errors.append(err)
            if errors:
                raise ValidationError(errors)
        return value
1063653
def _run_validators(self, value):
        
        if value in self.empty_values:
            return

        errors = []
        for validator in self.validators:
            try:
                validator(value)
            except exceptions.ValidationError as err:
                if isinstance(err.messages, dict):
                    errors.append(err.messages)
                else:
                    errors.extend(err.messages)

        if errors:
            raise exceptions.ValidationError(errors)
1322003
def Any(*validators):
    
    @wraps(Any)
    def built(value):
        error = None
        for validator in validators:
            try:
                return validator(value)
            except Error as e:
                error = e
        raise error
    return built
1351197
def validate(*keys, &validator)
      key = flatten_keys(keys)
      values = validators[key] || []
      values << validator
      validators[key] = values
    end
604707
def _validate(self, value):
        
        errors = []
        kwargs = {}
        for validator in self.validators:
            try:
                r = validator(value)
                if not isinstance(validator, Validator) and r is False:
                    self.fail('validator_failed')
            except ValidationError as err:
                kwargs.update(err.kwargs)
                if isinstance(err.messages, dict):
                    errors.append(err.messages)
                else:
                    errors.extend(err.messages)
        if errors:
            raise ValidationError(errors, **kwargs)
71347
def play_all_validators(self, validators, value):
        
        successes = list()
        failures = OrderedDict()
        for validator in validators:
            name = get_callable_name(validator)
            try:
                res = validator(value)
                if result_is_success(res):
                    successes.append(name)
                else:
                    failures[validator] = res

            except Exception as exc:
                failures[validator] = exc

        return successes, failures
116987
def run_validators(self, value):
        
        errors = []
        for validator in self.validators:
            if hasattr(validator, 'set_context'):
                validator.set_context(self)

            try:
                validator(value)
            except ValidationError as exc:
                # If the validation error contains a mapping of fields to
                # errors then simply raise it immediately rather than
                # attempting to accumulate a list of errors.
                if isinstance(exc.detail, dict):
                    raise
                errors.extend(exc.detail)
            except DjangoValidationError as exc:
                errors.extend(exc.messages)
        if errors:
            raise ValidationError(errors)
617452
def validate(self):
        """"""
        if self.error:
            return False

        for v in self.validators:
            self.error = v(self.value)
            if self.error:
                return False

        return True