public function RecursiveContextualValidator::validate in Zircon Profile 8.0
Same name in this branch
- 8.0 vendor/symfony/validator/Validator/RecursiveContextualValidator.php \Symfony\Component\Validator\Validator\RecursiveContextualValidator::validate()
- 8.0 core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php \Drupal\Core\TypedData\Validation\RecursiveContextualValidator::validate()
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php \Drupal\Core\TypedData\Validation\RecursiveContextualValidator::validate()
Validates a value against a constraint or a list of constraints.
If no constraint is passed, the constraint \Symfony\Component\Validator\Constraints\Valid is assumed.
Parameters
mixed $value: The value to validate
\Symfony\Component\Validator\Constraint|\Symfony\Component\Validator\Constraint[] $constraints: The constraint(s) to validate against.
array|null $groups: The validation groups to validate, defaults to "Default".
bool $is_root_call: (optional) Whether its the most upper call in the typed data tree.
Return value
$this
Overrides ContextualValidatorInterface::validate
See also
\Symfony\Component\Validator\Constraints\Valid
1 call to RecursiveContextualValidator::validate()
- RecursiveContextualValidator::validatePropertyValue in core/
lib/ Drupal/ Core/ TypedData/ Validation/ RecursiveContextualValidator.php - Validates a value against the constraints specified for an object's property.
File
- core/
lib/ Drupal/ Core/ TypedData/ Validation/ RecursiveContextualValidator.php, line 89 - Contains \Drupal\Core\TypedData\Validation\RecursiveContextualValidator.
Class
- RecursiveContextualValidator
- Defines a recursive contextual validator for Typed Data.
Namespace
Drupal\Core\TypedData\ValidationCode
public function validate($data, $constraints = NULL, $groups = NULL, $is_root_call = TRUE) {
if (isset($groups)) {
throw new \LogicException('Passing custom groups is not supported.');
}
if (!$data instanceof TypedDataInterface) {
throw new \InvalidArgumentException('The passed value must be a typed data object.');
}
// You can pass a single constraint or an array of constraints.
// Make sure to deal with an array in the rest of the code.
if (isset($constraints) && !is_array($constraints)) {
$constraints = array(
$constraints,
);
}
$this
->validateNode($data, $constraints, $is_root_call);
return $this;
}