Password Validation

Published by Pickle in

Create a function that validates a password to conform to the following rules:

  • Length between 6 and 24 characters.
  • At least one uppercase letter (A-Z).
  • At least one lowercase letter (a-z).
  • At least one digit (0-9).
  • Maximum of 2 repeated characters.
    • "aa" is OK ๐Ÿ‘
    • "aaa" is NOT OK ๐Ÿ‘Ž
  • Supported special characters:
    • ! @ # $ % ^ & * ( ) + = _ - { } [ ] : ; " ' ? < > , .

Examples

ValidatePassword("P1zz@") โžž false
// Too short.

ValidatePassword("iLoveYou") โžž false
// Missing a number.

ValidatePassword("Fhg93@") โžž true
// OK!

Notes

N/A

Watch a quick demo on how Edabit works.