From 6cfd9410d6821623a5f828ea683cb15588363ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:19:48 +0300 Subject: [PATCH] update-import-validation-message --- app/Abstracts/Import.php | 13 ++++++++++++- resources/lang/en-GB/validation.php | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Abstracts/Import.php b/app/Abstracts/Import.php index f29adeda2..327c64d2e 100644 --- a/app/Abstracts/Import.php +++ b/app/Abstracts/Import.php @@ -122,7 +122,18 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow } catch (ValidationException $e) { foreach ($e->validator->failed() as $attribute => $value) { foreach ($value as $rule => $params) { - $validator->addFailure($row . '.' . $attribute, $rule, $params); + if ($rule === 'In' && !empty($params)) { + $actual_value = $data[$attribute] ?? 'null'; + $expected_values = implode(', ', $params); + $custom_message = trans('validation.in_detailed', [ + 'attribute' => $attribute, + 'value' => $actual_value, + 'values' => $expected_values + ]); + $validator->errors()->add($row . '.' . $attribute, $custom_message); + } else { + $validator->addFailure($row . '.' . $attribute, $rule, $params); + } } } diff --git a/resources/lang/en-GB/validation.php b/resources/lang/en-GB/validation.php index 4ffe075a3..976679b1e 100644 --- a/resources/lang/en-GB/validation.php +++ b/resources/lang/en-GB/validation.php @@ -66,6 +66,7 @@ return [ 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'in_array' => 'The :attribute field does not exist in :other.', + 'in_detailed' => 'The :attribute value ":value" is invalid. Expected one of: :values', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', 'ipv4' => 'The :attribute must be a valid IPv4 address.',