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.',