vendredi 14 décembre 2018

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

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire