Fix OTC order date validation
This commit is contained in:
@@ -53,7 +53,11 @@ if ($totalPrice === null || $totalPrice <= 0) {
|
||||
|
||||
$orderDateTime = DateTimeImmutable::createFromFormat('!Y-m-d', $orderDate);
|
||||
$orderDateErrors = DateTimeImmutable::getLastErrors();
|
||||
if ($orderDateTime === false || $orderDateErrors === false || $orderDateErrors['warning_count'] > 0 || $orderDateErrors['error_count'] > 0) {
|
||||
if ($orderDateTime === false) {
|
||||
json_response(422, ['ok' => false, 'error' => 'Invalid order date']);
|
||||
}
|
||||
|
||||
if (is_array($orderDateErrors) && (($orderDateErrors['warning_count'] ?? 0) > 0 || ($orderDateErrors['error_count'] ?? 0) > 0)) {
|
||||
json_response(422, ['ok' => false, 'error' => 'Invalid order date']);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user