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();
    }
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();
    }
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 ( ) ; }
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
Get a default validator .