2

you can at yii2 in the Model Rules enter patterns in passwords ? Tips for a rule that at least one uppercase character and at least one number ? Thanks so much

Rules

['password', 'pattern' => '(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20}'],
Saba
  • 105
  • 1
  • 12

1 Answers1

4

Your case probably does not work because for some reason Yii2 does not recognize \d or \p so you have to write this part manually or find a way around.

I have tested this one:

/^(?=.*[0-9])(?=.*[A-Z])([a-zA-Z0-9]+)$/

This means it will require at least one upper-case letter and at least one digit (lower-case letters are not necessary).

Gytis TG
  • 6,700
  • 17
  • 33
  • 50