public function IsNullValidator::validate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Constraints/IsNullValidator.php \Symfony\Component\Validator\Constraints\IsNullValidator::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 IsNullValidator::validate()
- IsNullConstraintValidator::validate in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ IsNullConstraintValidator.php - Checks if the passed value is valid.
1 method overrides IsNullValidator::validate()
- IsNullConstraintValidator::validate in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ IsNullConstraintValidator.php - Checks if the passed value is valid.
File
- vendor/
symfony/ validator/ Constraints/ IsNullValidator.php, line 27
Class
- IsNullValidator
- @author Bernhard Schussek <bschussek@gmail.com>
Namespace
Symfony\Component\Validator\ConstraintsCode
public function validate($value, Constraint $constraint) {
if (!$constraint instanceof IsNull) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\IsNull');
}
if (null !== $value) {
if ($this->context instanceof ExecutionContextInterface) {
$this->context
->buildViolation($constraint->message)
->setParameter('{{ value }}', $this
->formatValue($value))
->addViolation();
}
else {
$this
->buildViolation($constraint->message)
->setParameter('{{ value }}', $this
->formatValue($value))
->addViolation();
}
}
}