class ComplexDataConstraintValidator
Same name in other branches
- 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraintValidator
- 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraintValidator
- 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraintValidator
Validates complex data.
Hierarchy
- class \Drupal\Core\Validation\Plugin\Validation\Constraint\ComplexDataConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator uses \Drupal\Core\TypedData\Validation\TypedDataAwareValidatorTrait
Expanded class hierarchy of ComplexDataConstraintValidator
File
-
core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ ComplexDataConstraintValidator.php, line 15
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class ComplexDataConstraintValidator extends ConstraintValidator {
use TypedDataAwareValidatorTrait;
/**
* {@inheritdoc}
*/
public function validate($data, Constraint $constraint) {
// If un-wrapped data has been passed, fetch the typed data object first.
if (!$data instanceof TypedDataInterface) {
$data = $this->getTypedData();
}
if (!$data instanceof ComplexDataInterface) {
throw new UnexpectedTypeException($data, 'ComplexData');
}
foreach ($constraint->properties as $name => $constraints) {
$this->context
->getValidator()
->inContext($this->context)
->validate($data->get($name), $constraints, NULL, FALSE);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ComplexDataConstraintValidator::validate | public | function | |
TypedDataAwareValidatorTrait::getTypedData | public | function | Gets the typed data object for the validated value. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.