0
votes

I know how do make custom validation in Laravel. But how do I create a validation rule that a input value has to be greater than other input value? (I know how to do it within the controller, but how do I do it using Validator class in Laravel?)

1

1 Answers

1
votes

I would extend Laravel Validator class and add a new method:

protected function validateGreaterThanInput($attribute, $value, $parameters){
    return $this->getSize($attribute) > $this->getSize($parameters[0]); 
}

Then in your validation rules you can use something like:

$rules = [
    'input' => 'greaterThanInput:secondInput'
];

I think that should do the trick.