Sets the validator.

@param string $validator
968656
public function setValidator($validator)
    {
        if (!($validator instanceof LibBaseControllerValidatorAbstract)) {
            if (is_string($validator) && strpos($validator, '.') === false) {
                $identifier = clone $this->getIdentifier();
                $identifier->path = array('controller', 'validator');
                $identifier->name = $validator;
                register_default(array('identifier' => $identifier, 'prefix' => $this));
            } else {
                $identifier = $this->getIdentifier($validator);
            }

            if ($identifier->path[1] != 'validator') {
                throw new AnControllerBehaviorException('Identifier: '.$identifier.' is not a validator identifier');
            }

            $validator = $identifier;
        }

        $this->_validator = $validator;
    }
73286
protected function registerValidationRules($validator)
    {
        /**
         * elfinder validator
         */
        $validator->resolver(function($translator, $data, $rules, $messages)
        {
            return new BaseValidator($translator, $data, $rules, $messages);
        });
        $validator->replacer('elfinder_max', function($message, $attribute, $rule, $parameters) {
            return str_replace(':size',$parameters[0],$message);
        });
        $validator->replacer('elfinder', function($message, $attribute, $rule, $parameters) {
            return str_replace(':values',implode(', ', $parameters),$message);
        });

    }
1170416
public function addValidator(ValidatorInterface $validator)
    {
        foreach ((array) $validator->getGroups() as $group_name) {
            if (false === array_key_exists($group_name, $this->validators)) {
                $this->validators[$group_name] = array();
            }

            $this->validators[$group_name][] = $validator;
        }
    }
788451
public function withValidator($validator): void
    {
        $user = $this->user($this->route('guard'));

        $validator->after(function ($validator) use ($user) {
            if (! $user->phone || ! $user->hasVerifiedPhone()) {
                $validator->errors()->add('phone', trans('cortex/auth::messages.account.'.(! $user->phone ? 'phone_field_required' : 'phone_verification_required')));
            }
        });
    }
792014
public function validationDefault(Validator $validator) : Validator
    {
        // configurable in config/csv_migrations.php
        if (! Configure::read('CsvMigrations.tableValidation')) {
            return $validator;
        }

        return $this->validationEnabled($validator);
    }
840529
public function setValidator(ValidatorExtensionInterface $validator)
    {
        $this->validator = $validator;
        $this->validator->setFormHandler($this);
    }
1026538
public function validate($validator)
    {
        // false signifies invalid value due to failed parse()
        if ($this->value !== false) {
            return true;
        }

        $validator->validationError(
            $this->name,
            _t(
                'SilverStripe\\Forms\\NumericField.VALIDATION',
                "'{value}' is not a number, only numbers can be accepted for this field",
                ['value' => $this->originalValue]
            )
        );
        return false;
    }
641350
public function extend($validator)
	{
		$validator = is_array($validator) ? $validator : [$validator];

		$this->validators = array_merge($this->validators, $validator);

		return $this;
	}
1291870
private static function checkValidator($validator)
    {
        if (!array_key_exists($validator, self::$validators)) {
            return self::checkClass($validator);
        }
        return self::$validators[$validator];
    }
890233
public function setValidator($validator, array $options = null) {
		if ($validator instanceof ZendValidatorInterface) {
			$this->validator = $validator;
		}
		else if (is_string($validator)) {
			$class = 'Zend_Validate_' . ucfirst($validator);
			
			if ($options === null) {
				$this->validator = new $class();
			} else {
				$this->validator = new $class($options);
			}
		}
		else {
			throw new ValidationFailure('Invalid Zend validator definition');
		}
	}
1347168
protected function useValidator(Validator $validator)
    {
        if (substr($this->account, 2, 2) == '99') {
            return $validator === $this->validators[2]
                || $validator === $this->validators[3];

        } else {
            return  $validator !== $this->validators[2];

        }
    }
667716
public function validate($validator)
    {
        if ($this->checkHostname($this->Value())) {
            return true;
        }

        $validator->validationError(
            $this->getName(),
            _t('DomainNameField.INVALID_DOMAIN', 'Invalid domain name'),
            'validation'
        );
        return false;
    }
560445
public function addValidators(Validator\ValidatorInterface ...$validators) {
        foreach($validators as $validator) {
            $this->addValidator($validator);
        }
        return $this;
    }
700626
protected function failedValidation(Validator $validator)
    {
        throw (new ValidationException($validator))
                    ->errorBag($this->errorBag)
                    ->redirectTo($this->getRedirectUrl());
    }
1036346
public static function set_password_validator(PasswordValidator $validator = null)
    {
        // Override existing config
        Config::modify()->remove(Injector::class, PasswordValidator::class);
        if ($validator) {
            Injector::inst()->registerService($validator, PasswordValidator::class);
        } else {
            Injector::inst()->unregisterNamedObject(PasswordValidator::class);
        }
    }
86018
protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ValidationHttpException($validator->errors());
        }

        parent::failedValidation($validator);
    }
63540
protected function callValidator($validator)
    {
        if (is_callable($validator)) {
            try {
                call_user_func_array($validator, array($this->value));
            } catch (\Exception $ex) {
                $this->error = $ex->getMessage();
                return false;
            }
        }
    }