public function MinQtyLessThanOrEqualMaxQtyConstraintValidator::validate in Commerce Product Bundle 8
@inheritdoc
File
- src/
Plugin/ Validation/ Constraint/ MinQtyLessThanOrEqualMaxQtyConstraintValidator.php, line 16
Class
- MinQtyLessThanOrEqualMaxQtyConstraintValidator
- Validates the MinQtyLessThanOrEqualMaxQty constraint.
Namespace
Drupal\commerce_product_bundle\Plugin\Validation\ConstraintCode
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();
}
}