Injects the validator function.
@param {Function} validator The validator function that should be injected
763524
function (validator) {
    if (!_.isFunction(validator)) {
      var err = new Error('Please pass in a function');
      debug(err);
      throw err;
    }
    if (validator.length == 2) {
      return this.validator = validator;
    }

    this.validator = function (data, callback) {
      callback(validator(data));
    };

    return this.validator;
  }
933706
function(name, validator) {
    var async = this.isAsync(name);
    var rule = new Rule(name, rules[name], async);
    rule.setValidator(validator);
    return rule;
  }
1203242
function addValidations(scope, validations) {
        for (var name in validations) {
            if (validations.hasOwnProperty(name) && validations[name]) {
                scope[name] = $injector.invoke(validations[name]);
            }
        }
    }
580017
public void addValidator(final FieldValidator validator) {
		WComponent labelField = findComponentForLabel(field);

		if (labelField instanceof Input) {
			((Input) labelField).addValidator(validator);
		}
	}
1361714
private void notifyOnValidationFailure(@NonNull final Validator<CharSequence> validator) {
        for (ValidationListener<CharSequence> validationListener : validationListeners) {
            validationListener.onValidationFailure(this, validator);
        }
    }
1266750
public function addValidation(Validator $validator) {
		$fields = (array)$this->getConfig('dummyField');
		foreach ($fields as $field) {
			$validator->requirePresence($field);
			$validator->allowEmpty($field);
			$validator->add($field, [
				$field => [
					'rule' => function ($value, $context) {
						return $value === '';
					},
					'last' => true
				],
			]);
		}
	}
890456
function () {
            this.errors = {};
            return flatten(this._static.validators.map(function runValidator(validator) {
                var col = validator.col, val = this.__values[validator.col], ret = validator.validate(val);
                this.errors[col] = ret;
                return ret;
            }, this));
        }
1138976
public function setValidator($validator)
    {
        $this->clearCache();
        $this->validators = [];
        $this->addValidator($validator);

        return $this;
    }
445761
public final void setValidator(@NonNull final Validator<Type> validator) {
        Condition.INSTANCE.ensureNotNull(validator, "The validator may not be null");
        this.validator = validator;
    }
1291870
private static function checkValidator($validator)
    {
        if (!array_key_exists($validator, self::$validators)) {
            return self::checkClass($validator);
        }
        return self::$validators[$validator];
    }
39694
public function addValidator(ValidatorInterface $validator)
    {
        if ($validator instanceof tao_helpers_form_validators_NotEmpty) {
            $this->addAttribute('required', true);
        }
        $this->validators[] = $validator;
    }
1055382
public function addValidator(callable $validator, string $validator_name): self
    {
        $this->validators[$validator_name] = $validator;

        return $this;
    }
365749
protected function _setValidator($validator)
    {
        if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
        }

        $this->validator = $validator;
    }
954009
public function setValidator(Validator $validator) {
        $this->_validator = $validator;

        // Only set model events if we plan on validating
        $this->on('model', $this);

        return $this;
    }
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.');
    }
}
1368747
protected function _addValidatorProps($validator = [])
    {
        foreach ($validator as $key => $value) {
            if (!isset($value) || empty($value)) {
                continue;
            }
            if ($key === 'rule' && is_array($value) && !is_callable($value)) {
                $this->_pass = array_slice($value, 1);
                $value = array_shift($value);
            }
            if (in_array($key, ['rule', 'on', 'message', 'last', 'provider', 'pass'])) {
                $this->{"_$key"} = $value;
            }
        }
    }
1092642
public function addValidator(Validator $validator) : ValidationCheckerInterface
    {
        $this->validated = false;
        $validator->setValidationSet($this);
        array_push($this->validators, $validator);
        return $this;
    }