From ea7b4639973c631df4c03ab23ee89bb6f09ddeae Mon Sep 17 00:00:00 2001 From: Siarhey Uchukhlebau Date: Tue, 7 Jun 2022 12:04:47 +0400 Subject: [PATCH] Fix preg_match arguments and condition in validation --- Model/Resolver/SetDeliveryDateOnCart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Resolver/SetDeliveryDateOnCart.php b/Model/Resolver/SetDeliveryDateOnCart.php index fc51e6e..13e205d 100644 --- a/Model/Resolver/SetDeliveryDateOnCart.php +++ b/Model/Resolver/SetDeliveryDateOnCart.php @@ -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.') );