Laravel use a custom validation message

Viewed 475

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.

1 Answers

If you want to pull a key from the translation file, then you need to pass it a key path in the form of file.key.subkey.subkey.

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