RecursiveContextualValidator::validateProperty

public RecursiveContextualValidator::validateProperty($object, $propertyName, $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:

array|null $groups The validation groups to validate. If: none is given, "Default" is assumed

Return value

ContextualValidatorInterface This validator

Overrides ContextualValidatorInterface::validateProperty

File

core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php, line 199

Class

RecursiveContextualValidator
Defines a recursive contextual validator for Typed Data.

Namespace

Drupal\Core\TypedData\Validation

Code

public function validateProperty($object, $propertyName, $groups = NULL) {
  if (isset($groups)) {
    throw new \LogicException('Passing custom groups is not supported.');
  }
  if (!is_object($object)) {
    throw new \InvalidArgumentException('Passing class name is not supported.');
  }
  elseif (!$object instanceof TypedDataInterface) {
    throw new \InvalidArgumentException('The passed in object has to be typed data.');
  }
  elseif (!$object instanceof ListInterface && !$object instanceof ComplexDataInterface) {
    throw new \InvalidArgumentException('Passed data does not contain properties.');
  }
  return $this->validateNode($object->get($propertyName), NULL, TRUE);
}
doc_Drupal
2016-10-29 09:36:47
Comments
Leave a Comment

Please login to continue.