Skip to content

Conversation

@mrvipchien
Copy link
Contributor

This PR fixes an issue where using Password::required() or Password::sometimes() inside an array of rules results in incorrect validation behavior.

When defining validation rules like:

$request->validate([
    'password' => ['confirmed', Password::required()],
]);

with the following payload:

{
    "password": "123",
    "password_confirmation": "123"
}

the validation does not work as expected.
The root cause is that Password::required() returns an array, which conflicts when it is placed inside another rule array.

This PR updated Password::required() so that it returns the rule instance instead of an array. This ensures the rule works correctly when used inside array-based validation.

@mrvipchien mrvipchien changed the title Fix required and sometimes validation of Password rule [12.x] Fix required and sometimes validation of Password rule Dec 6, 2025
@taylorotwell taylorotwell merged commit 3259346 into laravel:12.x Dec 6, 2025
74 checks passed
@mrvipchien mrvipchien deleted the fix-password-validation branch December 7, 2025 16:32
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