Reputation: 23
I have the following validation rule in my controller
"holder_name" => 'required_if:paymentMethod,==,credit_card',
That is, if paymentMethod = credit_card then holder_name is required / mandatory.
Now I need one more condition to be checked. I'll give the example as it would be in pure php, using if
For example I need to check if (paymentMethod = credit_card and card_id! = Null)
I already tried using two required_if:
'required_if:paymentMethod,==,credit_card'|'required_if:card_id,!=,null'
But it does not work.
Upvotes: 1
Views: 90
Reputation: 38922
Use the following rule for your validation.
The required_with
rule mandates a field if any of listed ones are non-empty.
'required_if:paymentMethod,credit_card|required_with:card_id'
Upvotes: 1