Graeme1995
10 months ago

How to validate that a field must be true if another field is false

Posted 10 months ago by Graeme1995

Below is a snippet of my validation currently:


            'independent_financial_advisor' => 'required|boolean',
            'understand_objective' => 'required|boolean',
            'confirm_objective' => 'required|boolean',
            'understand_term_held' => 'required|boolean',
            'tax_relief' => 'required|boolean',


I need to validate that when "independent_financial_advisor" is false, the remaining 4 fields below must be true. I could not find any Laravel rule which could do this so I thought about using a closure to create a custom rule. The issue with this is that I don't know how to reference another field in a closure to check its value.

What is the best way to go about this? Thanks

Please sign in or create an account to participate in this conversation.