Get the validator instance for the request.

@return \Illuminate\Contracts\Validation\Validator
176218
protected function getValidatorInstance(): Validator
    {
        $factory = $this->container->make(ValidationFactory::class);

        if (method_exists($this, 'validator')) {
            $validator = $this->container->call([$this, 'validator'], compact('factory'));
        } else {
            $validator = $this->createDefaultValidator($factory);
        }

        if (method_exists($this, 'withValidator')) {
            $this->withValidator($validator);
        }

        return $validator;
    }
914515
public function getFlattenValidators()
    {
        if (!$this->exists) {
            return [];
        }

        $validators = $this->validators;
        $return     = [];
        if (!empty($validators)) {
            foreach ($validators as $validator) {
                $return[$validator->validator_id] = $validator->value;
            }
        }
        return $return;
    }
1309498
public function setValidator(Validator $validator)
    {
        if ($validator) {
            $this->validator = $validator;
            $this->validator->setForm($this);
        }
        return $this;
    }
127864
public static function password_validator()
    {
        if (Injector::inst()->has(PasswordValidator::class)) {
            return Injector::inst()->get(PasswordValidator::class);
        }
        return null;
    }
1219228
public function getValidator()
    {
        if (!$this->validator) {
            $default_validator_class = Validator::CLASS;
            $validator_implementor = $this->getOption(self::OPTION_VALIDATOR, $default_validator_class);

            if (!class_exists($validator_implementor, true)) {
                throw new InvalidConfigException(
                    sprintf(
                        "Unable to resolve validator implementor '%s' given for attribute '%s' on entity type '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType()->getName()
                    )
                );
            }

            $validator = new $validator_implementor($this->getName(), $this->buildValidationRules());
            if (!$validator instanceof ValidatorInterface) {
                throw new InvalidTypeException(
                    sprintf(
                        "Invalid validator implementor '%s' given for attribute '%s' on entity type '%s'. " .
                        "Make sure to implement '%s'.",
                        $validator_implementor,
                        $this->getName(),
                        $this->getType() ? $this->getType()->getName() : 'undefined',
                        ValidatorInterface::CLASS
                    )
                );
            }
            $this->validator = $validator;
        }

        return $this->validator;
    }
485539
protected function getDefaultValidator(): ValidatorInterface
    {
        $loaders = [new StaticMethodLoader()];

        if (class_exists(AnnotationReader::class) && class_exists(ArrayCache::class)) {
            AnnotationRegistry::registerUniqueLoader('class_exists');
            $loaders[] = new AnnotationLoader(new CachedReader(new AnnotationReader(), new ArrayCache()));
        }

        return (new ValidatorBuilder())
            ->setMetadataFactory(
                new LazyLoadingMetadataFactory(
                    new LoaderChain($loaders)
                )
            )
            ->getValidator();
    }
293829
public function validate()
    {
        /** @var ValidationResult $validation */
        $validation = parent::validate();
        if (!$validation->isValid()) {
            return $validation;
        }

        $blog = $this->Blog();
        if (!$blog || !$blog->exists()) {
            return $validation;
        }

        if ($this->getDuplicatesByField('Title')->count() > 0) {
            $validation->addError($this->getDuplicateError(), self::DUPLICATE_EXCEPTION);
        }

        return $validation;
    }
471747
public function getValidator()
    {
        if (!isset($this->validator) && isset($this->configuration)) {
            // Initialize JSON validator.
            $resolver = $this->configuration->getResolver();
            if ($resolver && ($retriever = $resolver->getUriRetriever())) {
                $check_mode = JsonSchema\Validator::CHECK_MODE_NORMAL;
                $this->validator = new JsonSchema\Validator($check_mode, $retriever);
            }
        }

        return $this->validator;
    }
1107446
private function getValidator()
    {
        if (null === $this->validator) {
            $hook = function ($uri) {
                return $this->uriToFile($uri);
            };

            $this->validator = SchemaValidator::buildDefault($hook);
        }

        return $this->validator;
    }
6728
public function validateData()
    {
        $constraint = new Assert\Collection([
            'fields' => $this->getValidationRules(),
        ]);

        $violations = $this->validator->validate($this->getParameters(), $constraint);
        if ($violations->count()) {
            throw new ValidatorException($violations);
        }

        return $this;
    }
1197985
public function getValidator()
    {
        if (!$this->_validator instanceof LibBaseControllerValidatorAbstract) {
            //Make sure we have a view identifier
           if (!($this->_validator instanceof AnServiceIdentifier)) {
               $this->setValidator($this->_validator);
           }

            $config = array(
                'controller' => $this->getMixer(),
           );

            $this->_validator = $this->getService($this->_validator, $config);
        }

        return $this->_validator;
    }
942763
public function makeValidator($validator = null)
    {
        $validator = !is_null($validator) ? $validator : $this->validator();

        if (!is_null($validator)) {
            $this->validator = is_string($validator) ? $this->app->make($validator) : $validator;

            if (!$this->validator instanceof ValidatorInterface) {
                throw new RepositoryException("Class {$validator} must be an instance of Prettus\\Validator\\Contracts\\ValidatorInterface");
            }

            return $this->validator;
        }

        return null;
    }
731088
public static function populateValidator(Validator $validator)
	{
		if (static::$provider === null)
		{
			static::setProvider(new FromArray(true, 'validation'));
		}

		return static::$provider->populateValidator($validator);
	}
838999
public static Validator getExperimentalValidator() {
        return CascadingValidator.create(
                ParenthesesValidator.INSTANCE,
                ConfigurableValidator.create(ValidatorConfiguration.createExperimental()));
    }
1062055
public function getLoaders()
    {
        $loaders = array();
        foreach ($this->validators as $validator) {
            $loaders[$validator->getName()] = $validator->getLoader();
        }

        return $loaders;
    }
406577
public function validator($validator, $condition = true)
    {
        if (!$condition) {
            return $this;
        }

        if ($validator instanceof \Closure) {
            $this->validators[] = $validator;
        } else {
            $this->rule($validator);
        }

        return $this;
    }
940702
public function getValidators() {
		if ($this->_validators === false) {
			return;
		}
		
		if ($this->_validators === null) {
			$definition = $this->getValidationDefinition();
			
			if ($definition === null) {
				$this->_validators = false;
				return;
			}
			
			$validators = [];
			
			foreach ($definition as $propName => $propValidators) {
				$propValidators = (array) $propValidators;
				
				if (! isset($validators[$propName])) {
					$validators[$propName] = [];
				}
				
				foreach ($propValidators as $name => $validatorDefinition) {
					if ($validatorDefinition instanceof ValidatorInterface) {
						$validators[$propName][$name] = $validatorDefinition;
					}
					else if (is_string($validatorDefinition)) {
						$validator = $this->getValidatorsLocator()->get($validatorDefinition);
						
						if (! $validator instanceof ValidatorInterface) {
							throw new Exception('Validator must implements "ValidatorInterface" interface');
						}
						
						$validators[$propName][$name] = $validator;
					}
					else if (is_array($validatorDefinition)) {
						if (! isset($validatorDefinition[0]) || ! is_string($validatorDefinition[0])) {
							throw new Exception('Invalid validator definition for the "' . $propName . '" property');
						}
						
						$validatorName = $validatorDefinition[0];
						unset($validatorDefinition[0]);
						
						$validator = $this->getValidatorsLocator()->getByArguments($validatorName, [$validatorDefinition]);
						
						if (! $validator instanceof ValidatorInterface) {
							throw new Exception('Validator must implements "ValidatorInterface" interface');
						}
						
						$validators[$propName][$name] = $validator;
					}
					else {
						throw new Exception('Invalid validator definition for the "' . $propName . '" property');
					}
				}
			}
			
			$this->_validators = $validators;
		}
		
		return $this->_validators;
	}