Password::defaults method

You can enforce specific rules when validating user-supplied passwords by using the Password::defaults method. It includes options for requiring letters, numbers, symbols, and more.

1class AppServiceProvider
2{
3 public function boot(): void
4 {
5 Password::defaults(function () {
6 return Password::min(12)
7 ->letters()
8 ->numbers()
9 ->symbols()
10 ->mixedCase()
11 ->uncompromised();
12 })
13 }
14}
15 
16request()->validate([
17 ['password' => ['required', Password::defaults()]]
18])

Tip given by @mattkingshott

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord