public function BlankValidator::validate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Constraints/BlankValidator.php \Symfony\Component\Validator\Constraints\BlankValidator::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
File
- vendor/
symfony/ validator/ Constraints/ BlankValidator.php, line 27
Class
- BlankValidator
- @author Bernhard Schussek <bschussek@gmail.com>
Namespace
Symfony\Component\Validator\ConstraintsCode
public function validate($value, Constraint $constraint) {
if (!$constraint instanceof Blank) {
throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\\Blank');
}
if ('' !== $value && 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();
}
}
}