Support the ongoing development of Laravel.io →
Validation Requests
Last updated 2 years ago.
0

Thank you, I already read the documentation, but I do not understand how to procede.

I would like to use my rules in several places of my application, so I suppose that I have to use a Validator class.

Where should I create it? Should I create it inside the "Services" folder?

Then I'm said to register that class with the code

    Validator::resolver(function($translator, $data, $rules, $messages)
    {
        return new CustomValidator($translator, $data, $rules, $messages); 
    });

Where should I put that code? In which class? In which function?

0

You can create a file called validatorResolver.php to put your resolver and include it somewhere. As for CustomValidator, you can always create a Validators folder inside the app and have you class there. It will be autoloaded directly.

0

Thank you, I've finally have it working.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Kumidan kumidan Joined 29 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.

© 2024 Laravel.io - All rights reserved.