You are here

public function NotNullConstraintValidator::validate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraintValidator.php \Drupal\Core\Validation\Plugin\Validation\Constraint\NotNullConstraintValidator::validate()

Checks if the passed value is valid.

Parameters

mixed $value The value that should be validated:

Constraint $constraint The constraint for the validation:

Overrides NotNullValidator::validate

File

core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraintValidator.php, line 28
Contains \Drupal\Core\Validation\Plugin\Validation\Constraint\NotNullConstraintValidator.

Class

NotNullConstraintValidator
NotNull constraint validator.

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint

Code

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);
}