Validation required_unless not working I have in a formRequest:
'left' => 'required_unless:right,1',
'right' => 'required_unless:left,1',
So basically what I want is to make each field required if the other is not selected. either left, or right is selected or both.
But the form is passing validation with neither selected.
Verified that the Request payload is sending those fields and they are:
{right: 0, left: 0}
But still validation fails.
Any ideas?
Thanks,
Dave
The code should work. Maybe the error is somewhere else? you're not referencing the correct formrequest class in the controller?
I dont know whats going on. All of a sudden every formRequest is not getting called. And I have hundred or so and I sure know I did not edit every one of of them in the last half hour to break them all!
Always something.
Ok solved.
Not sure what happened, reverted to half hour back version and all is good. Not sure why but its working.
Thanks for your time all the same :)
Dave
reverted to half hour back version and all is good. Not sure why but its working.
You could have run a diff between the 2 versions and it would have shown you only the lines that had changed in each file, if any.
Validation is still failing though.
Inside rules() i have:
\Log::info('INPUT');
\Log::info($input);
\Log::info('RULES');
\Log::info($rules);
Which shows:
[2019-06-25 15:24:30] local.INFO: INPUT
[2019-06-25 15:24:30] local.INFO: array (
'left' => 0,
'right' => 0
)
[2019-06-25 15:24:30] local.INFO: RULES
[2019-06-25 15:24:30] local.INFO: array (
'left' => 'required_unless:right,1',
'right' => 'required_unless:left,1',
)
But it is still failing to catch the rules.
Ok not ideal but solved by setting the checkbox false value to null so this validation works now:
'left' => 'required_without:right',
'right' => 'required_without:left',
Will use this for now.
Please sign in or create an account to participate in this conversation.