Validator deprecated

class Validator implements ValidatorInterface, MetadataFactoryInterface

deprecated

since version 2.5, to be removed in 3.0. Use {@link Validator\RecursiveValidator} instead.

Default implementation of {@link ValidatorInterface}.

Methods

__construct(MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, TranslatorInterface $translator, $translationDomain = 'validators', array $objectInitializers = array())
MetadataFactoryInterface getMetadataFactory()

Returns the factory for metadata instances.

MetadataInterface getMetadataFor(mixed $value)

Returns the metadata for the given value.

bool hasMetadataFor(mixed $value)

Returns whether the class is able to return metadata for the given value.

ConstraintViolationListInterface validate(mixed $value, array|null $groups = null, bool $traverse = false, bool $deep = false)

Validates a value.

ConstraintViolationListInterface validateProperty(mixed $containingValue, string $property, array|null $groups = null)

Validates a property of a value against its current value.

ConstraintViolationListInterface validatePropertyValue(mixed $containingValue, string $property, string $value, array|null $groups = null)

Validate a property of a value against a potential value.

ConstraintViolationListInterface validateValue(mixed $value, Constraint|Constraint[] $constraints, array|null $groups = null)

Validates a value against a constraint or a list of constraints.

Details

__construct(MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, TranslatorInterface $translator, $translationDomain = 'validators', array $objectInitializers = array())

Parameters

MetadataFactoryInterface $metadataFactory
ConstraintValidatorFactoryInterface $validatorFactory
TranslatorInterface $translator
$translationDomain
array $objectInitializers

MetadataFactoryInterface getMetadataFactory()

Returns the factory for metadata instances.

Return Value

MetadataFactoryInterface The metadata factory.

MetadataInterface getMetadataFor(mixed $value)

Returns the metadata for the given value.

Parameters

mixed $value Some value

Return Value

MetadataInterface The metadata for the value

Exceptions

NoSuchMetadataException If no metadata exists for the given value

bool hasMetadataFor(mixed $value)

Returns whether the class is able to return metadata for the given value.

Parameters

mixed $value Some value

Return Value

bool Whether metadata can be returned for that value

ConstraintViolationListInterface validate(mixed $value, array|null $groups = null, bool $traverse = false, bool $deep = false)

Validates a value.

The accepted values depend on the {@link MetadataFactoryInterface} implementation.

The signature changed with Symfony 2.5 (see {@link Validator\ValidatorInterface::validate()}. This signature will be disabled in Symfony 3.0.

Parameters

mixed $value The value to validate
array|null $groups The validation groups to validate.
bool $traverse Whether to traverse the value if it is traversable.
bool $deep Whether to traverse nested traversable values recursively.

Return Value

ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded.

ConstraintViolationListInterface validateProperty(mixed $containingValue, string $property, array|null $groups = null)

Validates a property of a value against its current value.

The accepted values depend on the {@link MetadataFactoryInterface} implementation.

Parameters

mixed $containingValue The value containing the property.
string $property The name of the property to validate.
array|null $groups The validation groups to validate.

Return Value

ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded.

ConstraintViolationListInterface validatePropertyValue(mixed $containingValue, string $property, string $value, array|null $groups = null)

Validate a property of a value against a potential value.

The accepted values depend on the {@link MetadataFactoryInterface} implementation.

Parameters

mixed $containingValue The value containing the property.
string $property The name of the property to validate
string $value The value to validate against the constraints of the property.
array|null $groups The validation groups to validate.

Return Value

ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded.

ConstraintViolationListInterface validateValue(mixed $value, Constraint|Constraint[] $constraints, array|null $groups = null)

Validates a value against a constraint or a list of constraints.

Parameters

mixed $value The value to validate.
Constraint|Constraint[] $constraints The constraint(s) to validate against.
array|null $groups The validation groups to validate.

Return Value

ConstraintViolationListInterface A list of constraint violations. If the list is empty, validation succeeded.
doc_Symfony
2016-10-28 06:36:35
Comments
Leave a Comment

Please login to continue.