Skip to content

Commit

Permalink
fix(consignment): only validate delivery date if needed (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Dec 31, 2021
1 parent 558e69a commit fce209d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Rule/Consignment/DeliveryDateRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class DeliveryDateRule extends Rule
public function validate($validationSubject): void
{
$isDefaultDeliveryType = AbstractConsignment::DEFAULT_DELIVERY_TYPE === $validationSubject->getDeliveryType();
$canHaveDeliveryDate = $validationSubject->canHaveExtraOption(AbstractConsignment::EXTRA_OPTION_DELIVERY_DATE);

if (! $isDefaultDeliveryType && ! $validationSubject->getDeliveryDate()) {
if (! $isDefaultDeliveryType && $canHaveDeliveryDate && ! $validationSubject->getDeliveryDate()) {
$this->addError(
sprintf(
'If delivery_type is not %d, delivery_date is required.',
Expand Down

0 comments on commit fce209d

Please sign in to comment.