laravel 自訂欄位驗證訊息

hsuan-ming Yang
2 min readAug 18, 2020

今日主題:預設的驗證訊息是 resources/lang/xx-xx/validation.php(這邊要看config/app.php的locale的設定)對應rules產生的驗證訊息,例如:required、unique、…

這邊說明“custom”、“attributes”欄位
# custom 自訂欄位驗證訊息$validate = Validator::make(Input::all(), [
'g-recaptcha-response' => 'required|captcha'
]);
# required 會對應到 custom => 'g-recaptcha-response' => 'required'
# attribute 被驗證的欄位名稱本地化'required'             => '注意: :attribute 字段必填.',# ... 省略 ...'attributes' => [
'username' => "帳號",
'password' => "密碼",
],
# ... 省略 ...

—完成 —

--

--