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

Validating Passwords with Password::min() rule #669

Open
LocalHeroPro opened this issue May 22, 2021 · 2 comments
Open

Validating Passwords with Password::min() rule #669

LocalHeroPro opened this issue May 22, 2021 · 2 comments

Comments

@LocalHeroPro
Copy link

Subject of the issue

Want to use: https://laravel.com/docs/8.x/validation#validating-passwords.

Your environment

  • version of this package: 4.4.4
  • version of Laravel: 8.42.1

Steps to reproduce

Use:

'password' => [Password::min()],

Expected behaviour

Want to use: https://laravel.com/docs/8.x/validation#validating-passwords.

Actual behaviour

Frontend validator don't recognize that rule.

@bytestream
Copy link
Collaborator

Suggest to use #505 as that will work with unsupported rules

@ElawadyNet
Copy link

ElawadyNet commented Jun 9, 2021

Use new password rules as callback like:

return [
            'password' => [
                'required',
                function ($attribute, $value, $fail) {
                    $rule = new Password(10);
                    $rule->setData(['password' => $value]);
                    $rule->uncompromised()->letters()->numbers()->mixedCase();
                    $passes = $rule->passes('password', $value);
                    $messages = $rule->message();
                    if (!$passes) {
                        $fail(__($messages[0]));
                    }
                },
            ],
        ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants