class MinQtyLessThanOrEqualMaxQtyConstraintValidator in Commerce Product Bundle 8
Validates the MinQtyLessThanOrEqualMaxQty constraint.
Hierarchy
- class \Drupal\commerce_product_bundle\Plugin\Validation\Constraint\MinQtyLessThanOrEqualMaxQtyConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
Expanded class hierarchy of MinQtyLessThanOrEqualMaxQtyConstraintValidator
1 file declares its use of MinQtyLessThanOrEqualMaxQtyConstraintValidator
- MinQtyLessThanOrEqualMaxQtyConstraintValidatorTest.php in tests/
src/ Unit/ Plugin/ Validation/ Constraint/ MinQtyLessThanOrEqualMaxQtyConstraintValidatorTest.php
File
- src/
Plugin/ Validation/ Constraint/ MinQtyLessThanOrEqualMaxQtyConstraintValidator.php, line 11
Namespace
Drupal\commerce_product_bundle\Plugin\Validation\ConstraintView source
class MinQtyLessThanOrEqualMaxQtyConstraintValidator extends ConstraintValidator {
/**
* @inheritdoc
*/
public function validate($entity, Constraint $constraint) {
if (!isset($entity)) {
return;
}
$max = $entity
->getMaximumQuantity();
$min = $entity
->getMinimumQuantity();
if ($min > $max) {
$this->context
->buildViolation($constraint->message)
->setParameter('%min', $min)
->setParameter('%max', $max)
->addViolation();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MinQtyLessThanOrEqualMaxQtyConstraintValidator:: |
public | function | @inheritdoc |