public function RangeFromGreaterToConstraintValidator::validate in Range 8
File
- src/
Plugin/ Validation/ Constraint/ RangeFromGreaterToConstraintValidator.php, line 18
Class
- RangeFromGreaterToConstraintValidator
- Validates the RangeFromGreaterTo constraint.
Namespace
Drupal\range\Plugin\Validation\ConstraintCode
public function validate($value, Constraint $constraint) {
if (!$value instanceof RangeItemInterface) {
throw new UnexpectedTypeException($value, 'RangeItemInterface');
}
$range = $value
->getValue();
if ($range['from'] > $range['to']) {
$this->context
->addViolation($constraint->message);
}
}