class LegacyValidator extends RecursiveValidator

deprecated since version 2.5, to be removed in 3.0.

A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+.

Properties

protected $contextFactory from RecursiveValidator
protected $metadataFactory from RecursiveValidator
protected $validatorFactory from RecursiveValidator
protected $objectInitializers from RecursiveValidator

Methods

__construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array())

Creates a new validator.

startContext($root = null)

Starts a new validation context and returns a validator for that context.

inContext(ExecutionContextInterface $context)

Returns a validator in the given execution context.

getMetadataFor($object)

Returns the metadata for the given value.

bool
hasMetadataFor($object)

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

validate(mixed $value, string|GroupSequence|(string|GroupSequence)[]|null $groups = null, $traverse = false, $deep = false)

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

validateProperty(object $object, string $propertyName, string|GroupSequence|(string|GroupSequence)[]|null $groups = null)

Validates a property of an object against the constraints specified for this property.

validatePropertyValue(object|string $objectOrClass, string $propertyName, mixed $value, string|GroupSequence|(string|GroupSequence)[]|null $groups = null)

Validates a value against the constraints specified for an object's property.

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

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

getMetadataFactory()

Returns the factory for metadata instances.

Details

in RecursiveValidator at line 48
__construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array())

Creates a new validator.

Parameters

ExecutionContextFactoryInterface $contextFactory The factory for creating new contexts
MetadataFactoryInterface $metadataFactory The factory for fetching the metadata of validated objects
ConstraintValidatorFactoryInterface $validatorFactory The factory for creating constraint validators
array $objectInitializers The object initializers

in RecursiveValidator at line 59
ContextualValidatorInterface startContext($root = null)

Starts a new validation context and returns a validator for that context.

The returned validator collects all violations generated within its context. You can access these violations with the {@link ContextualValidatorInterface::getViolations()} method.

Parameters

$root

Return Value

ContextualValidatorInterface The validator for the new context

in RecursiveValidator at line 72
ContextualValidatorInterface inContext(ExecutionContextInterface $context)

Returns a validator in the given execution context.

The returned validator adds all generated violations to the given context.

Parameters

ExecutionContextInterface $context

Return Value

ContextualValidatorInterface The validator for that context

in RecursiveValidator at line 85
MetadataInterface getMetadataFor($object)

Returns the metadata for the given value.

Parameters

$object

Return Value

MetadataInterface The metadata for the value

Exceptions

NoSuchMetadataException If no metadata exists for the given value

in RecursiveValidator at line 93
bool hasMetadataFor($object)

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

Parameters

$object

Return Value

bool Whether metadata can be returned for that value

in RecursiveValidator at line 101
ConstraintViolationListInterface validate(mixed $value, string|GroupSequence|(string|GroupSequence)[]|null $groups = null, $traverse = false, $deep = false)

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

If no constraint is passed, the constraint {@link \Symfony\Component\Validator\Constraints\Valid} is assumed.

Parameters

mixed $value The value to validate
string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed
$traverse
$deep

Return Value

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

in RecursiveValidator at line 124
ConstraintViolationListInterface validateProperty(object $object, string $propertyName, string|GroupSequence|(string|GroupSequence)[]|null $groups = null)

Validates a property of an object against the constraints specified for this property.

Parameters

object $object The object
string $propertyName The name of the validated property
string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed

Return Value

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

in RecursiveValidator at line 134
ConstraintViolationListInterface validatePropertyValue(object|string $objectOrClass, string $propertyName, mixed $value, string|GroupSequence|(string|GroupSequence)[]|null $groups = null)

Validates a value against the constraints specified for an object's property.

Parameters

object|string $objectOrClass The object or its class name
string $propertyName The name of the property
mixed $value The value to validate against the property's constraints
string|GroupSequence|(string|GroupSequence)[]|null $groups The validation groups to validate. If none is given, "Default" is assumed

Return Value

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

in RecursiveValidator at line 145
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.

in RecursiveValidator at line 155
MetadataFactoryInterface getMetadataFactory()

Returns the factory for metadata instances.

Return Value

MetadataFactoryInterface The metadata factory