public function RecursiveValidator::validatePropertyValue

public RecursiveValidator::validatePropertyValue($objectOrClass, $propertyName, $value, $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

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 ValidatorInterface::validatePropertyValue

File

core/lib/Drupal/Core/TypedData/Validation/RecursiveValidator.php, line 106

Class

RecursiveValidator
Defines a recursive validator for Typed Data.

Namespace

Drupal\Core\TypedData\Validation

Code

public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = NULL) {
  // Just passing a class name is not supported.
  if (!is_object($objectOrClass)) {
    throw new \LogicException('Typed data validation does not support passing the class name only.');
  }
  return $this->startContext($objectOrClass)
    ->validatePropertyValue($objectOrClass, $propertyName, $value, $groups)
    ->getViolations();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!TypedData!Validation!RecursiveValidator.php/function/RecursiveValidator::validatePropertyValue/8.1.x