class RangeFromGreaterToConstraintValidator in Range 8
Validates the RangeFromGreaterTo constraint.
Hierarchy
- class \Drupal\range\Plugin\Validation\Constraint\RangeFromGreaterToConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of RangeFromGreaterToConstraintValidator
1 file declares its use of RangeFromGreaterToConstraintValidator
- RangeFromGreaterToConstraintValidatorTest.php in tests/
src/ Unit/ Plugin/ Validation/ Constraint/ RangeFromGreaterToConstraintValidatorTest.php
File
- src/
Plugin/ Validation/ Constraint/ RangeFromGreaterToConstraintValidator.php, line 13
Namespace
Drupal\range\Plugin\Validation\ConstraintView source
class RangeFromGreaterToConstraintValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
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);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RangeFromGreaterToConstraintValidator:: |
public | function | Checks if the passed value is valid. |