Support the ongoing development of Laravel.io →
Requests Validation

I can get validation to work for basic things using a Request and the authorize and rules sections of the request. I can use the method injection stuff in the controller, and everything works fine.

But if I want to get more complex than that, I'm totally lost.

I see lots of things along the lines of this

 $validator = Validator::make($postData, $rules, $messages);
    if ($validator->fails()) {
      // send back to the page with the input data and errors
      return Redirect::to('/account/formvalidate')->withInput()->withErrors($validator);
    }

Then you can do custom stuff if it fails.

For the life of me, I don't know how to make this all work in Laravel 5. The docs give examples of it, but never say where to put this. Does it go in the controller? The Request file?. Some places talk about making a new 'service provider' to do it?

I'm totally lost how to do custom validation stuff that does custom things on failure of validation.

I know this is a pretty vague question, but all the tutorials I find only cover the basics. Can someone point me to a good resource on understanding how controllers/requests/validation all play together?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Nertskull nertskull Joined 3 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.