Skip to content

[12.x] Handle null as a falsy condition #56612

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

Merged

Conversation

negoziator
Copy link
Contributor

What

Handle null as a falsy condition.

Why

The requiredIf constructor was type-improved in this commit, which no longer resolves null as a falsy value.

There's scenarios where it makes sense to handle null as a falsy value e.g

//  Some FormRequest rules
 ...
 'some_admin_key' => [new RequiredIf(user()?->isAdmin()), 'string'], // user() is null.

@taylorotwell taylorotwell merged commit fbfe9ad into laravel:12.x Aug 11, 2025
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants