I have the email and password fields in which I only want them to be required if the add_user field value is 1. This is my validation:
public function rules() {
return [
'add_user' => ['required'],
'password' => ['required_if:add_user,1', 'min:8'],
'email' => ['required_if:add_user,1', 'email', 'max:255'],
];
}
This one is not working, it always errors even if the value is 0. I fill out the add_user value using jquery. I have a drop down that if the user clicked from the options, add_user value is 0, but if thru input, value is 1. Values are correct but the validation isn't working. Can someone help me figure this out?