public function LegacyValidator::validate in Plug 7
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:
Constraint|Constraint[] $constraints The constraint(s) to validate: against
array|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
Overrides RecursiveValidator::validate
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ LegacyValidator.php, line 42
Class
- LegacyValidator
- A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+.
Namespace
Symfony\Component\Validator\ValidatorCode
public function validate($value, $groups = null, $traverse = false, $deep = false) {
$numArgs = func_num_args();
// Use new signature if constraints are given in the second argument
if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) {
// Rename to avoid total confusion ;)
$constraints = $groups;
$groups = $traverse;
return parent::validate($value, $constraints, $groups);
}
$constraint = new Valid(array(
'traverse' => $traverse,
'deep' => $deep,
));
return parent::validate($value, $constraint, $groups);
}