Suppose I have form wizard, I want to separate validation rules based on the wizard index, suppose I want to have the following validation rules if wizard_index
value is first
or all
or if wizard_index
not exists.
$rules = [
'wizard_index' => ['required', 'string', 'in:first,second,third,all'],
'name' => ['required_if:wizard_index,in:first,all', 'string', 'max:50', 'min:3'],
'about' => ['required_if:wizard_index,in:first,all', 'string', 'max:500', 'min:10'],
'size' => [
'required_if:wizard_index,in:first,last', 'string',
'in:0 - 1,2 - 10,11 - 50,51 - 200,201 - 500,"501 - 1,000","1,001 - 5,000","5,001 + more"'
]
];
Above validation rules not working, but if I remove in:
and check for only one value it's working.
And the last point is I want to remove required
rule from wizard_index
, and add one other extra condition for other fields that should be required if wizard_index
does not exist.
required_if
rule is a value – Salim Djerbouh