Skip to content

Custom specialCharsRegex requires 2 chars from list #61

@dylan-gregory

Description

@dylan-gregory

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions