automica's avatar

How to stack multiple validation rules

I'm working on a complex form that has a number of conditional fields.

I am having some issues with how best to stack these rules.

My example rules:

      [
                'bail',
                'required_if:current_employment_situation,working',
                'min:1',
                'numeric',
            ],

should require the field to be present if another field (which is a radio group) 'current_employment_situation' is set to 'working'.

My issue is that i only wish to do the additional validation if the required_if is required. Currently i don't want to check my field is min:1 or numeric unless it passes required_if step. So if the field isn't required dont bother checking any of the other validation steps.

Any idea how to do this (in Laravel 7 if that matters).

0 likes
2 replies

Please or to participate in this conversation.