Laravel驗證自定義消息我想問一下關於Laravel驗證一些建議......使用嵌套屬性
比方說,我有一個名爲invoiceAddress[name]
輸入和控制器我有一個規則
$rule = ['invoiceAddress.name' => 'required',];
,或只是一個
$validator = \Validator::make($request->all(), [
'invoiceAddress.name' => 'required',
]);
現在,內部自定義的驗證語言文件validation.php
,我能夠嵌套屬性不知何故?像:
'required' => ':attribute is mandatory',
'attributes' => [
'invoiceAddress' => [
'name' => 'blahblah'
],
],
如果我嘗試拼圖屬性上面的方式,我得到
ErrorException
mb_strtoupper() expects parameter 1 to be string, array given
因爲我使用的字段(如上)
['name' => 'blahblah']
我想使用該文件和:attribute
指令(如上面的代碼中所述)獲取自定義消息。
我基本上是試圖做到這一點How to set custom attribute labels for nested inputs in Laravel,但我得到了提到的錯誤...
預先感謝您...
什麼是validation.php你試圖實現的是你在驗證的消息中有問題嗎? –
validation.php是我的自定義驗證語言文件,我試圖使用已定義的屬性和':attribute'指令來獲取消息...而不是定義數百個自定義消息 –
此問題依然存在,您是否找到任何有效的解決方案? – Desh901