function IsNullConstraintValidator::validate

Same name in other branches
  1. 9 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator::validate()
  2. 8.9.x core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator::validate()
  3. 10 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\IsNullConstraintValidator::validate()

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/IsNullConstraintValidator.php, line 23

Class

IsNullConstraintValidator
Null constraint validator.

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

Code

public function validate($value, Constraint $constraint) : void {
    $typed_data = $this->getTypedData();
    if (($typed_data instanceof ListInterface || $typed_data instanceof ComplexDataInterface) && $typed_data->isEmpty()) {
        $value = NULL;
    }
    parent::validate($value, $constraint);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.