ValidatorBuilderInterface

interface ValidatorBuilderInterface

A configurable builder for ValidatorInterface objects.

Methods

$this addObjectInitializer(ObjectInitializerInterface $initializer)

Adds an object initializer to the validator.

$this addObjectInitializers(array $initializers)

Adds a list of object initializers to the validator.

$this addXmlMapping(string $path)

Adds an XML constraint mapping file to the validator.

$this addXmlMappings(array $paths)

Adds a list of XML constraint mapping files to the validator.

$this addYamlMapping(string $path)

Adds a YAML constraint mapping file to the validator.

$this addYamlMappings(array $paths)

Adds a list of YAML constraint mappings file to the validator.

$this addMethodMapping(string $methodName)

Enables constraint mapping using the given static method.

$this addMethodMappings(array $methodNames)

Enables constraint mapping using the given static methods.

$this enableAnnotationMapping(Reader $annotationReader = null)

Enables annotation based constraint mapping.

$this disableAnnotationMapping()

Disables annotation based constraint mapping.

$this setMetadataFactory(MetadataFactoryInterface $metadataFactory)

Sets the class metadata factory used by the validator.

$this setMetadataCache(CacheInterface $cache)

Sets the cache for caching class metadata.

$this setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory)

Sets the constraint validator factory used by the validator.

$this setTranslator(TranslatorInterface $translator)

Sets the translator used for translating violation messages.

$this setTranslationDomain(string $translationDomain)

Sets the default translation domain of violation messages.

$this setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) deprecated

Sets the property accessor for resolving property paths.

$this setApiVersion(int $apiVersion) deprecated

Sets the API version that the returned validator should support.

ValidatorInterface getValidator()

Builds and returns a new validator object.

Details

$this addObjectInitializer(ObjectInitializerInterface $initializer)

Adds an object initializer to the validator.

Parameters

ObjectInitializerInterface $initializer

Return Value

$this

$this addObjectInitializers(array $initializers)

Adds a list of object initializers to the validator.

Parameters

array $initializers

Return Value

$this

$this addXmlMapping(string $path)

Adds an XML constraint mapping file to the validator.

Parameters

string $path The path to the mapping file

Return Value

$this

$this addXmlMappings(array $paths)

Adds a list of XML constraint mapping files to the validator.

Parameters

array $paths The paths to the mapping files

Return Value

$this

$this addYamlMapping(string $path)

Adds a YAML constraint mapping file to the validator.

Parameters

string $path The path to the mapping file

Return Value

$this

$this addYamlMappings(array $paths)

Adds a list of YAML constraint mappings file to the validator.

Parameters

array $paths The paths to the mapping files

Return Value

$this

$this addMethodMapping(string $methodName)

Enables constraint mapping using the given static method.

Parameters

string $methodName The name of the method

Return Value

$this

$this addMethodMappings(array $methodNames)

Enables constraint mapping using the given static methods.

Parameters

array $methodNames The names of the methods

Return Value

$this

$this enableAnnotationMapping(Reader $annotationReader = null)

Enables annotation based constraint mapping.

Parameters

Reader $annotationReader

Return Value

$this

$this disableAnnotationMapping()

Disables annotation based constraint mapping.

Return Value

$this

$this setMetadataFactory(MetadataFactoryInterface $metadataFactory)

Sets the class metadata factory used by the validator.

Parameters

MetadataFactoryInterface $metadataFactory

Return Value

$this

$this setMetadataCache(CacheInterface $cache)

Sets the cache for caching class metadata.

Parameters

CacheInterface $cache

Return Value

$this

$this setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $validatorFactory)

Sets the constraint validator factory used by the validator.

Parameters

ConstraintValidatorFactoryInterface $validatorFactory

Return Value

$this

$this setTranslator(TranslatorInterface $translator)

Sets the translator used for translating violation messages.

Parameters

TranslatorInterface $translator

Return Value

$this

$this setTranslationDomain(string $translationDomain)

Sets the default translation domain of violation messages.

The same message can have different translations in different domains. Pass the domain that is used for violation messages by default to this method.

Parameters

string $translationDomain The translation domain of the violation messages

Return Value

$this

$this setPropertyAccessor(PropertyAccessorInterface $propertyAccessor) deprecated

deprecated

since version 2.5, to be removed in 3.0.

Sets the property accessor for resolving property paths.

Parameters

PropertyAccessorInterface $propertyAccessor The property accessor

Return Value

$this

$this setApiVersion(int $apiVersion) deprecated

deprecated

since version 2.7, to be removed in 3.0.

Sets the API version that the returned validator should support.

Parameters

int $apiVersion The required API version

Return Value

$this

See also

Validation::API_VERSION_2_5
Validation::API_VERSION_2_5_BC

ValidatorInterface getValidator()

Builds and returns a new validator object.

Return Value

ValidatorInterface The built validator

© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Component/Validator/ValidatorBuilderInterface.html