You are here

public function NotNullValidator::validate in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Constraints/NotNullValidator.php \Symfony\Component\Validator\Constraints\NotNullValidator::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 ConstraintValidatorInterface::validate

1 call to NotNullValidator::validate()
NotNullConstraintValidator::validate in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraintValidator.php
Checks if the passed value is valid.
1 method overrides NotNullValidator::validate()
NotNullConstraintValidator::validate in core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/NotNullConstraintValidator.php
Checks if the passed value is valid.

File

vendor/symfony/validator/Constraints/NotNullValidator.php, line 26

Class

NotNullValidator
@author Bernhard Schussek <bschussek@gmail.com>

Namespace

Symfony\Component\Validator\Constraints

Code

public function validate($value, Constraint $constraint) {
  if (!$constraint instanceof NotNull) {
    throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\NotNull');
  }
  if (null === $value) {
    $this->context
      ->addViolation($constraint->message);
  }
}