update-import-validation-message
This commit is contained in:
parent
0c7fa0cf0d
commit
6cfd9410d6
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.',
|
||||
|
|
|
|||
Loading…
Reference in New Issue