Skip to content

Commit

Permalink
Fix preg_match arguments and condition in validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheyUchukhlebau committed Jun 7, 2022
1 parent 9c11bf5 commit ea7b463
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Model/Resolver/SetDeliveryDateOnCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ protected function validateInput(array $inputData): void
throw new GraphQlInputException(__('Required parameter "delivery_date" is missing'));
}

if (empty($inputData['delivery_date']['time'])) {
if (!preg_match('^\d{1,2}:\d{1,2}_\d{1,2}:\d{1,2}$', $inputData['delivery_date']['time'])) {
if (!empty($inputData['delivery_date']['time'])) {
if (!preg_match('/^\d{1,2}:\d{1,2}_\d{1,2}:\d{1,2}$/', $inputData['delivery_date']['time'])) {
throw new GraphQlInputException(
__('The delivery time must be specified in 00:00_23:59 format, like 10:30_19:00.')
);
Expand Down

0 comments on commit ea7b463

Please sign in to comment.