A validator that composes multiple validators into one.

    When called on a value, it runs all wrapped validators.

    :param validators: Arbitrary number of validators.
    :type validators: callables

    .. versionadded:: 17.1.0
350562
def and_(*validators):
    
    vals = []
    for validator in validators:
        vals.extend(
            validator._validators
            if isinstance(validator, _AndValidator)
            else [validator]
        )

    return _AndValidator(tuple(vals))
1134819
def deserialize(self, value, **kwargs):
        
        for validator in self.validators:
            validator.validate(value, **kwargs)

        return value
756879
function check(value, ...validators) {
    let valid = false;
    _.each(validators, (validator) => {
        return !(valid = validator(value));
    });

    if (!valid) {
        throw new TypeError('Argument is not any of the accepted types.');
    }
}
128132
function Validator(validatorsNamesList) {
		// add default embedded validator name
		validatorsNamesList.unshift('vsGooglePlace');

		this._embeddedValidators = vsEmbeddedValidatorsInjector.get(validatorsNamesList);
		this.error = {};
		this.valid = true;
	}
43575
public T validator(MessageValidator<? extends ValidationContext> ... validators) {
        Stream.of(validators).forEach(getAction()::addValidator);
        return self;
    }
1055382
public function addValidator(callable $validator, string $validator_name): self
    {
        $this->validators[$validator_name] = $validator;

        return $this;
    }
758422
function normalizeValidator(validator) {
	        if (validator.validate !== undefined) {
	            return function (c) { return validator.validate(c); };
	        }
	        else {
	            return validator;
	        }
	    }
660807
def _output_validators(self):
        """"""
        if self._walk_for_type('Boolean'):
            print("from .validators import boolean")
        if self._walk_for_type('Integer'):
            print("from .validators import integer")
        vlist = self.override.get_validator_list()
        for override in vlist:
            if override.startswith('common/'):
                override = override.lstrip('common/')
                filename = "validators"
            else:
                filename = "%s_validators" % self.filename
            print("from .%s import %s" % (filename, override))
362046
def validate(self, value):
        
        for validate in self.validates:
            value = validate(value)
        return value
1229653
def _call_validators(self):
        
        msg = []
        msg.extend(self._validate_keyfile())
        msg.extend(self._validate_dns_zone())
        msg.extend(self._validate_retries())
        msg.extend(self._validate_project())
        return msg
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
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)
101645
def extend(validator_cls):
    

    Validator = jsonschema.validators.extend(
        validator_cls, {
            "properties": _properties_with_defaults(validator_cls),
        }
    )

    class Blueprinter(Validator):
        def instantiate(self, data):
            self.validate(data)
            return data

    return Blueprinter
1035535
def each_item(*validators):
    
    def validate(value):
        for item in value:
            for validator in validators:
                error = validator(item)
                if error:
                    return error
        return None
    return validate
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
1184867
function validatorWrapper(validators, name, validator) {
    return function (value, options) {
        var error = void 0,
            args = arguments;
        var alias = this && this.alias;
        var validatorObj = validators[name];
        var validatorAliasObj = alias ? validators[alias] : {};
        var arg = validatorObj[ARG] || validatorAliasObj[ARG] || validators[ARG];
        var isSimpleArgsFormat = validatorObj[SIMPLE_ARGS_FORMAT] || validatorAliasObj[SIMPLE_ARGS_FORMAT] || validators[SIMPLE_ARGS_FORMAT];

        options = assign({}, validatorObj.defaultOptions, validatorAliasObj.defaultOptions, options);

        if (typeof options.parse === 'function') {
            value = options.parse(value);
        }

        if (options.hasOwnProperty(arg) && !isSimpleArgsFormat) {
            args = [value, options[arg]].concat(Array.prototype.slice.call(arguments, 1));
        }

        try {
            var resultHandler = validatorObj[RESULT_HANDLER] || validatorAliasObj[RESULT_HANDLER] || validators[RESULT_HANDLER];

            error = resultHandler(validator.apply(validators, args));
        } catch (err) {
            var exceptionHandler = validatorObj[EXCEPTION_HANDLER] || validatorAliasObj[EXCEPTION_HANDLER] || validators[EXCEPTION_HANDLER];

            if (typeof exceptionHandler === 'function') {
                error = exceptionHandler(err);
            } else {
                throw err;
            }
        }

        function handleError(error) {
            if (error) {
                var _ret = function () {
                    var errorObj = (typeof error === 'undefined' ? 'undefined' : _typeof(error)) === 'object' ? error : null; //in case if we rewrite message in options and want to use fields from error object in the placeholders
                    var message = options[MESSAGE] || validatorObj[MESSAGE] || validatorAliasObj[MESSAGE];

                    if (message) {
                        error = message;
                    }

                    var formattedErrorMessage = validators.formatMessage(error, assign({ validator: alias || name, value: value }, errorObj, options));
                    var format = validatorObj[ERROR_FORMAT] || validatorAliasObj[ERROR_FORMAT] || validators[ERROR_FORMAT];

                    if (format) {
                        if (typeof formattedErrorMessage === 'string') {
                            formattedErrorMessage = { message: formattedErrorMessage };
                        }

                        if (format.$options) {
                            format = assign({}, format);

                            Object.keys(options).forEach(function (key) {
                                if (!MESSAGE_REGEXP.test(key) && typeof options[key] !== 'function') {
                                    format[key] = options[key];
                                }
                            });
                        }
                        delete format.$options;

                        if (format.$origin) {
                            format = assign({}, format, formattedErrorMessage);
                        }
                        delete format.$origin;

                        return {
                            v: validators.formatMessage(format, assign({ validator: alias || name, value: value }, options, formattedErrorMessage))
                        };
                    }

                    return {
                        v: formattedErrorMessage
                    };
                }();

                if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v;
            }
        }

        return (typeof error === 'undefined' ? 'undefined' : _typeof(error)) === 'object' && typeof error.then === 'function' ? error.then(handleError) : handleError(error);
    };
}
52065
def validate(self, value=None, model=None, context=None):
        
        errors = []
        for validator in self.validators:
            if value is None and not isinstance(validator, Required):
                continue

            error = validator.run(
                value=value,
                model=model,
                context=context if self.use_context else None
            )
            if error:
                errors.append(error)

        return errors