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\PropertyAccess\PropertyAccessorInterface;
16 use Symfony\Component\Translation\TranslatorInterface;
17 use Symfony\Component\Validator\Mapping\Cache\CacheInterface;
20 * A configurable builder for ValidatorInterface objects.
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 interface ValidatorBuilderInterface
27 * Adds an object initializer to the validator.
29 * @param ObjectInitializerInterface $initializer The initializer
33 public function addObjectInitializer(ObjectInitializerInterface $initializer);
36 * Adds a list of object initializers to the validator.
38 * @param array $initializers The initializer
42 public function addObjectInitializers(array $initializers);
45 * Adds an XML constraint mapping file to the validator.
47 * @param string $path The path to the mapping file
51 public function addXmlMapping($path);
54 * Adds a list of XML constraint mapping files to the validator.
56 * @param array $paths The paths to the mapping files
60 public function addXmlMappings(array $paths);
63 * Adds a YAML constraint mapping file to the validator.
65 * @param string $path The path to the mapping file
69 public function addYamlMapping($path);
72 * Adds a list of YAML constraint mappings file to the validator.
74 * @param array $paths The paths to the mapping files
78 public function addYamlMappings(array $paths);
81 * Enables constraint mapping using the given static method.
83 * @param string $methodName The name of the method
87 public function addMethodMapping($methodName);
90 * Enables constraint mapping using the given static methods.
92 * @param array $methodNames The names of the methods
96 public function addMethodMappings(array $methodNames);
99 * Enables annotation based constraint mapping.
101 * @param Reader $annotationReader The annotation reader to be used
105 public function enableAnnotationMapping(Reader $annotationReader = null);
108 * Disables annotation based constraint mapping.
112 public function disableAnnotationMapping();
115 * Sets the class metadata factory used by the validator.
117 * @param MetadataFactoryInterface $metadataFactory The metadata factory
121 public function setMetadataFactory(MetadataFactoryInterface $metadataFactory);
124 * Sets the cache for caching class metadata.
126 * @param CacheInterface $cache The cache instance
130 public function setMetadataCache(CacheInterface $cache);
133 * Sets the constraint validator factory used by the validator.
135 * @param ConstraintValidatorFactoryInterface $validatorFactory The validator factory
139 public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory);
142 * Sets the translator used for translating violation messages.
144 * @param TranslatorInterface $translator The translator instance
148 public function setTranslator(TranslatorInterface $translator);
151 * Sets the default translation domain of violation messages.
153 * The same message can have different translations in different domains.
154 * Pass the domain that is used for violation messages by default to this
157 * @param string $translationDomain The translation domain of the violation messages
161 public function setTranslationDomain($translationDomain);
164 * Sets the property accessor for resolving property paths.
166 * @param PropertyAccessorInterface $propertyAccessor The property accessor
170 * @deprecated since version 2.5, to be removed in 3.0.
172 public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor);
175 * Sets the API version that the returned validator should support.
177 * @param int $apiVersion The required API version
181 * @see Validation::API_VERSION_2_5
182 * @see Validation::API_VERSION_2_5_BC
183 * @deprecated since version 2.7, to be removed in 3.0.
185 public function setApiVersion($apiVersion);
188 * Builds and returns a new validator object.
190 * @return ValidatorInterface The built validator
192 public function getValidator();