Returns validator instance

@return  Validator
765795
public function getValidator(): Validator
    {
        if ($this->validator === null) {
            $this->validator = new Validator(new ValidatorCollection(), $this->getPlaceholder());
        }

        return $this->validator;
    }
831250
private function getInstance()
    {
        if (is_null($this->instance)) {
            $this->instance = \RegexGuard\Factory::getGuard();
        }
        
        return $this->instance;
    }
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;
    }
161624
public function addValidator($validator)
    {
        if (!($validator instanceof ValidatorInterface) && !is_callable($validator)) {
            $validator = ValidatorHelper::create($validator);
        }

        $this->validator->addValidator($validator);

        return $this;
    }
530997
public static function instance(): self
    {
        if (!self::$instance) {
            self::$instance = new self(
                StubFactory::instance(),
                StubVerifierFactory::instance(),
                EmptyValueFactory::instance(),
                AssertionRenderer::instance(),
                ExceptionAssertionRecorder::instance(),
                Invoker::instance()
            );
        }

        return self::$instance;
    }
27563
public function getValidator()
    {
        if (!$this->validator) {
            $this->setValidator(
                $this->validatorFactory->createValidator($this->form)
            );
        }

        return $this->validator;
    }
91560
public static function validator($validator = null)
    {
        if (func_num_args()) {
            static::$_validators[static::class] = $validator;
            return;
        }
        $self = static::class;
        if (isset(static::$_validators[$self])) {
            return static::$_validators[$self];
        }
        $class = static::$_classes['validator'];
        $validator = static::$_validators[$self] = new $class();
        static::_rules($validator);
        return $validator;
    }
1084701
public function error()
    {
        $errors = $this->validator->errors();

        $this->error = empty($errors) ?: array_pop($errors)[0];

        return $this->error;
    }
1196813
private static function checkClass($validator)
    {
        if (! class_exists($validator)) {
            throw new InvalidArgumentException(
                "Class {$validator} does not exists."
            );
        }

        if (! is_subclass_of($validator, ValidatorInterface::class)) {
            throw new Exception\UnknownValidatorClassException(
                "The validator '{$validator}' is not defined or does not " .
                "implements the Slick\\Validator\\ValidatorInterface interface"
            );
        }

        return $validator;
    }
838999
public static Validator getExperimentalValidator() {
        return CascadingValidator.create(
                ParenthesesValidator.INSTANCE,
                ConfigurableValidator.create(ValidatorConfiguration.createExperimental()));
    }
1158687
public function setValidator(Validator $validator)
    {
        $this->validator = $validator;
        
        $validator->configureRule($this);
        
        return $this;
    }
132154
public function createValidator()
    {
        $sv = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
        $validator = new Validator($sv);

        return $validator;
    }
1002385
protected function attachValidator()
    {
        return ValidatorFacade::resolver(function($translator, $data, $rules, $messages) {
                    return new CustomValidator($translator, $data, $rules, $messages);
                });
    }
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;
	}
840041
public function validator($resource=null)
    {

        $resource = $this->passedOrCurrent($resource);

        if ($class = $this->mapper->validatorClass($resource)) {
            return $this->makeValidator($resource, $class);
        }

        $modelClass = class_basename($this->modelClass($resource));

        if ($class = $this->finder->validatorClass($resource, $modelClass)) {
            return $this->makeValidator($resource, $class);;
        }

        $class = 'Cmsable\Resource\GenericResourceValidator';

        if ($rules = $this->getManualRules($resource)) {
            $validator = $this->makeValidator($resource, $class);
            return $validator->setRules($rules);
        }

        // Support for rules inside forms
        if (!$this->hasForm($resource)) {
            throw new RuntimeException('No validator for resource $resource found');
        }


        if ($rules = $this->formRules($this->form(null, $resource))) {
             $validator = $this->makeValidator($resource, $class);
             return $validator->setRules($rules);

        }

        throw new RuntimeException('No validator for resource $resource found');

    }
102369
public static function create($validator, $message = null)
    {
        $class = self::checkValidator($validator);

        /** @var ValidatorInterface $object */
        $object = new $class;
        if (!is_null($message)) {
            $object->setMessage($message);
        }
        return $object;
    }
1207372
public function validation()
    {
        $validator = new Validation();

        $validator->add(
            'name',
            new PresenceOf([
                'model' => $this,
                'required' => true,
            ])
        );

        return $this->validate($validator);
    }