class NotNullValidator
@author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\ConstraintValidator implements \Symfony\Component\Validator\ConstraintValidatorInterface
- class \Symfony\Component\Validator\Constraints\NotNullValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of NotNullValidator
1 file declares its use of NotNullValidator
- NotNullConstraintValidator.php in core/
lib/ Drupal/ Core/ Validation/ Plugin/ Validation/ Constraint/ NotNullConstraintValidator.php
File
-
vendor/
symfony/ validator/ Constraints/ NotNullValidator.php, line 21
Namespace
Symfony\Component\Validator\ConstraintsView source
class NotNullValidator extends ConstraintValidator {
public function validate(mixed $value, Constraint $constraint) : void {
if (!$constraint instanceof NotNull) {
throw new UnexpectedTypeException($constraint, NotNull::class);
}
if (null === $value) {
$this->context
->buildViolation($constraint->message)
->setParameter('{{ value }}', $this->formatValue($value))
->setCode(NotNull::IS_NULL_ERROR)
->addViolation();
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
ConstraintValidator::$context | protected | property | |||
ConstraintValidator::formatTypeOf | protected | function | Returns a string representation of the type of the value. | ||
ConstraintValidator::formatValue | protected | function | Returns a string representation of the value. | ||
ConstraintValidator::formatValues | protected | function | Returns a string representation of a list of values. | ||
ConstraintValidator::initialize | public | function | Initializes the constraint validator. | Overrides ConstraintValidatorInterface::initialize | |
ConstraintValidator::OBJECT_TO_STRING | public | constant | Whether to cast objects with a "__toString()" method to strings. | ||
ConstraintValidator::PRETTY_DATE | public | constant | Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s"). |
||
NotNullValidator::validate | public | function | Checks if the passed value is valid. | Overrides ConstraintValidatorInterface::validate | 1 |