我需要驗證具有圖像和標籤的請求。如何爲標記返回常見的驗證錯誤消息。如何獲得陣列字段的常見驗證錯誤消息
$this->validate($request, [
'image' => 'required|image,
'tags.*' => 'string'
]);
Currecnt message is。
{
"image": [
"The image field is required."
],
"tags.0": [
"The tags.0 must be a string."
],
"tags.1": [
"The tags.1 must be a string."
]
}
預期消息是。
{
"image": [
"The image field is required."
],
"tags": [
"The tags must be a string."
]
}
消息已更改。但它來自多個數組索引。 「tags.0」:[ 「標籤必須是字符串。」 ], 「tags.1」:[ 「標籤必須是字符串。」 ] – noufalcep
@noufalcep這是因爲你有多個不正確的字段的數組輸入字段 –
是的。我需要多個輸入的單個錯誤消息。 – noufalcep