4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator;
14 use Doctrine\Common\Annotations\Reader;
15 use Symfony\Component\Translation\TranslatorInterface;
16 use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
17 use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface;
18 use Symfony\Component\Validator\Validator\ValidatorInterface;
21 * A configurable builder for ValidatorInterface objects.
23 * @author Bernhard Schussek <bschussek@gmail.com>
25 interface ValidatorBuilderInterface
28 * Adds an object initializer to the validator.
32 public function addObjectInitializer(ObjectInitializerInterface $initializer);
35 * Adds a list of object initializers to the validator.
37 * @param ObjectInitializerInterface[] $initializers
41 public function addObjectInitializers(array $initializers);
44 * Adds an XML constraint mapping file to the validator.
46 * @param string $path The path to the mapping file
50 public function addXmlMapping($path);
53 * Adds a list of XML constraint mapping files to the validator.
55 * @param string[] $paths The paths to the mapping files
59 public function addXmlMappings(array $paths);
62 * Adds a YAML constraint mapping file to the validator.
64 * @param string $path The path to the mapping file
68 public function addYamlMapping($path);
71 * Adds a list of YAML constraint mappings file to the validator.
73 * @param string[] $paths The paths to the mapping files
77 public function addYamlMappings(array $paths);
80 * Enables constraint mapping using the given static method.
82 * @param string $methodName The name of the method
86 public function addMethodMapping($methodName);
89 * Enables constraint mapping using the given static methods.
91 * @param string[] $methodNames The names of the methods
95 public function addMethodMappings(array $methodNames);
98 * Enables annotation based constraint mapping.
102 public function enableAnnotationMapping(Reader $annotationReader = null);
105 * Disables annotation based constraint mapping.
109 public function disableAnnotationMapping();
112 * Sets the class metadata factory used by the validator.
116 public function setMetadataFactory(MetadataFactoryInterface $metadataFactory);
119 * Sets the cache for caching class metadata.
123 public function setMetadataCache(CacheInterface $cache);
126 * Sets the constraint validator factory used by the validator.
130 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory);
133 * Sets the translator used for translating violation messages.
137 public function setTranslator(TranslatorInterface $translator);
140 * Sets the default translation domain of violation messages.
142 * The same message can have different translations in different domains.
143 * Pass the domain that is used for violation messages by default to this
146 * @param string $translationDomain The translation domain of the violation messages
150 public function setTranslationDomain($translationDomain);
153 * Builds and returns a new validator object.
155 * @return ValidatorInterface The built validator
157 public function getValidator();