-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
is_required validation rule is broken with boolean values (regression) #36540
Comments
Hi Philippe, First off, I'm sorry that my PR has caused this bug for you. The underlying issue is when and how Validator::validate(
['age' => false],
['foo' => 'required_if,age,0,1,2']
); Prior to my bugfix (which addressed a different scenario) I can't think of any way to make both of our examples work as we each expect. However, because your example was previously working, I feel my bugfix should probably be reverted for 6.x and 8.x. There is probably a bigger discussion to be had about how this should work in future versions though, because ultimately I feel the stricter validation is preferable, even if it means you may need to specify |
@dvlpp why do you have |
@jessarcher you're right, the solution is |
Although I agree with the easy suggest fix, just wanna bring to light that the validator, as per the docs, considers From the docs:
And to possibly add to the confusion, the |
@timacdonald yeah I did consider that actually and that made me think a bit about this. My thinking was "required_if" is not really boolean related - to me it seems like it should be a fairly literal check. |
Just wanted to report that this same issue caused problems in my applications. The validation rule below worked fine before v8.31, but broke unexpectedly after a 'subject' => 'exclude_unless:with_action,1|required|string|max:255', Is is too late to revert this breaking change? |
Yeah this ship has sailed I'm afraid. |
Too bad, I probably won't be the last one to get bitten by this breaking change |
Description:
It seems that this PR broke
required_if
validation rule with boolean values. Here's a validation rule which worked until 8.31:But since 8.32.0 this will pass without ValidationException with
is_organization
send to false andpersonal_occupation
to null (or empty).The text was updated successfully, but these errors were encountered: