Validates complex data.
Expanded class hierarchy of ComplexDataConstraintValidator
class ComplexDataConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
if (!isset($value)) {
return;
}
if (!$value instanceof ComplexDataInterface) {
throw new UnexpectedTypeException($value, 'ComplexData');
}
$group = $this->context
->getGroup();
foreach ($constraint->properties as $name => $constraints) {
$property = $value
->get($name);
$is_container = $property instanceof ComplexDataInterface || $property instanceof ListInterface;
if (!$is_container) {
$property = $property
->getValue();
}
elseif ($property
->isEmpty()) {
// @see \Drupal\Core\TypedData\Validation\PropertyContainerMetadata::accept();
$property = NULL;
}
$this->context
->validateValue($property, $constraints, $name, $group);
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ComplexDataConstraintValidator:: |
public | function |
Checks if the passed value is valid. Overrides ConstraintValidatorInterface:: |
|
ConstraintValidator:: |
protected | property | ||
ConstraintValidator:: |
public | function |
Initializes the constraint validator. Overrides ConstraintValidatorInterface:: |
1 |