public function Validator::validate

Validates a value.

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

@api

Parameters

mixed $value The value to validate:

array|null $groups The validation groups to validate.:

Boolean $traverse Whether to traverse the value if it is traversable.:

Boolean $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

drupal/core/vendor/symfony/validator/Symfony/Component/Validator/Validator.php, line 85

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();
}