0

I've created a class that extends LaravelValidatior and a method that needs to check some rules. For example

class ExtendLaravelValidator extends LaravelValidator { 
    public function validateRequiredIfSomething($attribute, $value, $parameters)
    {
        if(something())
        {
            return true;
        }

        return false;
    }
}

Also I have some rules:

class CreateCompanyValidator extends Validator {
    protected static $rules = [
        'name'                  => 'required_if_something',
        'address'               => 'required_if_something',
}

As you probably figured it out, I need to call that required_if_something method always. It needs to act like laravel's required method. With each post I need to go thru all this fields. How can I accomplish that?

Filip Zelic
  • 110
  • 10

1 Answers1

0

If you are 100% sure you want to always use your extended class instead of Laravel's validator, you could change it in aliases array in your app.php file.

dominiczaq
  • 343
  • 2
  • 9