I need to write some validation rules for a user password with the following requirements. C# ASP.NET MVC.
Passwords must be 6 - 8 characters
Must include at least one character each from at least three of the following categories:
- Upper-case letters
- Lower-case letters
- Numeric digits
- Non-alpha-numeric characters (e.g.,!@#$%...)
Must not contain any sequence of 3 or more characters in common with the username
Must not repeat any of the previous 1 passwords
Must be changed if the password is believed to be compromised in any way
Currently i've written a bunch of really messy validation rules using if statements and loops (especially the 3 characters in sequence with username part), which is currently functional but it just feels like its wrong. Is there a better approach I can take?
Thankyou
See Question&Answers more detail:os