lundi 4 février 2019

Custom form validation in laravel 5.4 wihtout using AppServiceProvider boot() method

Currently I have a form I am validating like so:

class AppServiceProvider extends ServiceProvider
{
    public function boot()
    {
        \Validator::extend('custom_validation',function($attribute, $value, $parameters){
             //validation logic
      });
    }
...

But is there a way I avoid having to place this method in the AppServiceProvider (or any service provide for that matter)?

Is there a way for me to insert it somewhere in the controller class for example (for simplicity's sake)?

I like a variant like using a making a request class (extending FormRequest) but not sure how to add the custom method to the request class.

Any suggestions would be greatly appreciated. Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2GeDocT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire