Get a default validator.

By default the usage of annotations to validate object is off. To enable annotation configuration install
`doctrine/annotations` and `doctrine/cache`.

@return RecursiveValidator|ValidatorInterface
@throws AnnotationException
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();
    }
441538
public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('name');

        $validator
            ->allowEmpty('bio');

        $validator
            ->allowEmpty('url');

        $validator
            ->allowEmpty('company');

        $validator
            ->allowEmpty('location');

        return $validator;
    }
1365765
protected function getValidatorInstance()
    {
        $factory = $this->app()->make(Factory::class);

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

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

        return $validator;
    }
85853
public function getDefault()
    {
        if ($this->reflection->isDefaultValueAvailable()
            and $default = $this->reflection->getDefaultValue()
        ) {
            if (is_scalar($default)) {
                return $default;
            } else {
                return $this->tostring($default);
            }
        }
        if ($this->reflection->isArray()) {
            return '[]';
        }
        if ($this->isPassedByReference()) {
            return 'null';
        } elseif ($this->reflection->getClass()) {
            // This gets injected as a new instance.
            return null;
        }
        $type = $this->getType();
        if (!$type) {
            $type = $this->extractParameterData();
        }
        // Guesstimated values:
        switch ($type) {
            case 'int': case 'integer': case 'float':
                return 0;
            case 'string':
                return "''";
            case 'array':
                return '[]';
        }
        return null;
    }
235776
protected function validation()
    {
        if (null === $this->validation) {
            $this->validation = new ValidationBuilder($this);
        }

        return $this->validation;
    }
766481
public function getAnnotationDriver() {
    if (!isset($this->annotationDriver)) {
      $this->annotationDriver = new AnnotationDriver($this->getDefaultAnnotationReader(),
                                                     array((string) $this->getEntitiesPath())
                                                    );
    }
    
    return $this->annotationDriver;
  }
27584
public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('uid', 'create');

        $validator
            ->requirePresence('username', 'create')
            ->notEmpty('username');

        $validator
            ->requirePresence('password', 'create')
            ->notEmpty('password');

        $validator
            ->requirePresence('role', 'create')
            ->notEmpty('role')
            ->add('role', 'inList', [
                'rule' => ['inList', ['admin', 'author']],
                'message' => 'Please enter a valid role'
            ]);

        $validator
            ->boolean('verified')
            ->requirePresence('verified', 'create')
            ->notEmpty('verified');

        $validator
            ->email('email')
            ->requirePresence('email', 'create')
            ->notEmpty('email');

        return $validator;
    }
693987
public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create');

        $validator
            ->requirePresence('upload_id', 'create')
            ->notEmpty('upload_id');

        $validator
            ->requirePresence('original_filename', 'create')
            ->notEmpty('original_filename');

        $validator
            ->requirePresence('unique_filename', 'create')
            ->notEmpty('unique_filename');

        $validator
            ->allowEmpty('subfolder');

        $validator
            ->allowEmpty('mimetype');

        $validator
            ->add('size', 'valid', ['rule' => 'numeric'])
            ->requirePresence('size', 'create')
            ->notEmpty('size');

        $validator
            ->requirePresence('hash', 'create')
            ->notEmpty('hash');

        $validator
            ->add('upload_complete', 'valid', ['rule' => 'boolean'])
            ->requirePresence('upload_complete', 'create')
            ->notEmpty('upload_complete');

        $validator
            ->allowEmpty('label');

        $validator
            ->add('created_by', 'valid', ['rule' => 'numeric'])
            ->requirePresence('created_by', 'create')
            ->notEmpty('created_by');

        $validator
            ->add('modified_by', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('modified_by');

        return $validator;
    }
30373
private Validator createDefaultValidator() {
        final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
        final Validator validator = validatorFactory.usingContext()
                .getValidator();
        
        return validator;
    }
1092260
public function getValidatorsLocator() {
		if ($this->_validatorsLocator === null) {
			if ($this->hasLocator()) {
				$this->_validatorsLocator = $this->getLocator()->get('validatorsLocator');
				
				if (! $this->_validatorsLocator instanceof LocatorByArgumentsInterface) {
					throw new Exception('Validators\' locator must implements "LocatorByArgumentsInterface" interface');
				}
			} else {
				throw new Exception('Unable to provide validators\' locator');
			}
		}
		
		return $this->_validatorsLocator;
	}
160850
public function getRuleProviderDefault() : RuleProviderInterface
    {
        $container = Dependency::container();
        return $container->has('validate') ? $container->get('validate') : Validate::getInstance();
    }
423609
public function validationDefault(Validator $validator) {
		$validator
			->integer('id')
			->allowEmpty('id', 'create');

		$validator
			->requirePresence('ip', 'create')
			->notEmpty('ip');

		$validator
			->requirePresence('session_id', 'create')
			->notEmpty('session_id');

		$validator
			->allowEmpty('result');

		$validator
			->dateTime('used')
			->allowEmpty('used');

		return $validator;
	}
238773
public function getValidator(): ?Factory
    {
        if (!$this->hasValidator()) {
            $this->setValidator($this->getDefaultValidator());
        }
        return $this->validator;
    }
548953
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->requirePresence('name', 'create')
            ->notEmpty('name');

        $validator
            ->allowEmpty('color');

        $validator
            ->allowEmpty('icon');

        $validator
            ->allowEmpty('source');

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

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

        return $this->validator;
    }
53421
public function getValidator()
    {
        if (!$this->_validator instanceof AnDomainValidatorAbstract) {
            if (!$this->_validator instanceof AnServiceIdentifier) {
                $this->setValidator($this->_validator);
            }

            $config = array(
                'description' => $this->_repository->getDescription(),
            );

            $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;
    }