How can I get the build in error message when using form-request?

Posted 1 year ago by malhayek

I am using Laravel 5.5 in a project.

When I use the $request->validate([....]); directly in the controller to validate an incoming request, everything works fine, and if there is an error, the correct error message will be shown under the field. For example "This field is required".

However, if I use form-request to separate my validation process from the controller, I get this text instead "validation.required". I am aware that I can use the messages() method in my form-request to write custom messages. But if I don't define the messages() method, why doesn't Laravel just display similar message like it would in the controller?

It is possible that I am doing something wrong here.

How can I display the default error messages with form-request

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.