Skip to content

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
*/
public function __construct($condition)
{
if (is_null($condition)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to learn why is_null = false, and instead of is_empty = false.

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.

3 participants