简体   繁体   中英

Laravel use a custom validation message

I have made a custom rule in Laravel 5.5, but also want to get a custom translation with it from the lang validation file. For that I have now done:

'custom' => [
    'validate' => [
        'correct_password' => 'The :attribute is incorrect.',
    ],
],

And I put this in the custom rule file:

 return trans('validate.correct_password');

What have I done wrong to get the custom message? Because I get now only back the key: validate.correct_password as a message.

如果要从转换文件中提取密钥,则需要以file.key.subkey.subkey的形式传递密钥路径。

return trans('validation.custom.validate.correct_password');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM