class IsNullConstraintValidator
Same name in other branches
- 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator
- 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator
- 11.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator
Null constraint validator.
Overrides the symfony validator to handle empty Typed Data structures.
Hierarchy
- class \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator extends \Symfony\Component\Validator\Constraints\IsNullValidator uses \Drupal\Core\TypedData\Validation\TypedDataAwareValidatorTrait
Expanded class hierarchy of IsNullConstraintValidator
File
-
core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ IsNullConstraintValidator.php, line 16
Namespace
Drupal\Core\Validation\Plugin\Validation\ConstraintView source
class IsNullConstraintValidator extends IsNullValidator {
use TypedDataAwareValidatorTrait;
/**
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
$typed_data = $this->getTypedData();
if (($typed_data instanceof ListInterface || $typed_data instanceof ComplexDataInterface) && $typed_data->isEmpty()) {
$value = NULL;
}
parent::validate($value, $constraint);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
IsNullConstraintValidator::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.