You are here

public function Validator::validate in Plug 7

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.

@api

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.

Overrides ValidatorInterface::validate

File

lib/Symfony/validator/Symfony/Component/Validator/Validator.php, line 95

Class

Validator
Default implementation of {@link ValidatorInterface}.

Namespace

Symfony\Component\Validator

Code

public function validate($value, $groups = null, $traverse = false, $deep = false) {
  $visitor = $this
    ->createVisitor($value);
  foreach ($this
    ->resolveGroups($groups) as $group) {
    $visitor
      ->validate($value, $group, '', $traverse, $deep);
  }
  return $visitor
    ->getViolations();
}