I
I
Ivan2020-06-17 22:13:33
Laravel
Ivan, 2020-06-17 22:13:33

How in laravel in the validation class to check the fields relative to each other?

As in the request validation class, make a rule to compare two fields: so that the first cannot be greater than the second, and the second cannot be less than the first. Something like that:

public function rules()
    {
        return [
      'price_min' => 'required|integer|min:0',
      'price_max' => 'required|integer|min:0',
    ];
    }

How to add rules so that price_min cannot be greater than price_max and, accordingly, price_max cannot be less than price_min?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question