react-password-checklist icon indicating copy to clipboard operation
react-password-checklist copied to clipboard

Custom specialCharsRegex requires 2 chars from list

Open dylan-gregory opened this issue 5 months ago • 0 comments

Describe the bug When using the specialChar rule and specifying a custom specialCharsRegex, the password only validates after entering 2 characters from the custom list. It works as expected when not specifying custom regex

To Reproduce Steps to reproduce the behavior:

  1. Instantiate a PasswordChecklist
  2. Add the specialChar rule to the list of rules
  3. Add a specialCharsRegex prop to the Checklist and give it some regex (copying the default list is fine, for my specific case I wanted to lump numbers into this list, so my regex is /[~`¿¡!#$%\^&*€£@+÷=\-\[\]\\';,/{}\(\)|\\":<>\?\.\_1234567890]/g)
  4. Type a password with one single item from the custom list
  5. See that the specialChar rule is not met
  6. Type one more of those characters
  7. See the specialChar rule now get met

Expected behavior The specialChar rule should be met when using only one of the special characters, but it only validates after using 2

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: macOS 15.6
  • Browser: Chrome, Brave, Safari, FireFox
  • react-password-checklist version 1.8.1

dylan-gregory avatar Aug 14 '25 18:08 dylan-gregory