Skip to content

Add Password checking related validation rules #1

Description

@jwillp

Here are some levels used by applications to determine the strength of a password:

  1. Very weak: any character is allowed (example: "1234567890" or "qwerty")
  2. Weak: at least one lower and one upper
  3. Medium: at least one lower, one upper and one number
  4. Strong: at least one lower, one upper, one number and one special character
  5. Very strong: at least one lower, one upper, one number, one special character and a minimal length of 12

In order to support these various requirements, the following rules would be needed:

// Where numberCharacters means the number of required characters to match  
// strict = true means at most the provided number 
// while strict = false means at least the number of characters provided
new ContainsUppercaseCharacters($numberCharacters = 1, $strict = false, $message = null); 
new ContainsLowercaseCharacters($numberCharacters = 1, $strict = false, $message = null);
new ContainsNumericCharacters($numberCharacters = 1, $strict = false, $message = null);
// For Special characters, to allow users of the library to define their own set of special chars
new MatchesRegex($regex, $message);

// Min Length
new MinLength($length, $message);
new Length($length, $message); // For Exact length

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions