Skip to content
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

[8.x] Accept any instance of Rule and not just Password #37407

Merged
merged 1 commit into from
May 19, 2021

Conversation

crynobone
Copy link
Member

This would be useful if there a requirement to use custom Password implementation such as Laravel\Fortify\Rules\Password etc.

This would be useful if there a requirement to use custom Password implementation such as `Laravel\Fortify\Rules\Password` etc.
@@ -123,7 +123,7 @@ public static function default()
{
$password = value(static::$defaultCallback);

return $password instanceof static ? $password : static::min(8);
return $password instanceof Rule ? $password : static::min(8);
Copy link
Member

Choose a reason for hiding this comment

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

Surely self is the correct thing to put here?

Copy link
Member Author

@crynobone crynobone May 19, 2021

Choose a reason for hiding this comment

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

Laravel\Fortify\Rules\Password just implements Illuminate\Contracts\Validation\Rule. At current state you cannot set defaults by returning Laravel\Fortify\Rules\Password.

Copy link
Member Author

Choose a reason for hiding this comment

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

Without this changes:

use Laravel\Fortify\Rules\Password as FortifyPassword;
use Illuminate\Validation\Rules\Password;

Password::defaults(function () {
    return (new FortifyPassword())->length(10);
});

Password::defaults() // return Illuminate\Validation\Rules\Password with min 8 instead of 10.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I think we probs wanna add a test covering this, to check this doesn't break in the future.

@taylorotwell taylorotwell merged commit 273d27f into laravel:8.x May 19, 2021
@crynobone crynobone deleted the patch-1 branch November 19, 2021 00:48
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