Skip to content

Commit

Permalink
Update Password Regex (#20)
Browse files Browse the repository at this point in the history
- Replace password regex to include special characters
  • Loading branch information
RedDragonJ authored Jan 21, 2023
1 parent 0073e92 commit a9a8a2f
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import Foundation
public extension String {

/// Ensure is a valid password
/// Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet and 1 Number
/// Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character
/// - Returns: A boolean indicate if the password meet the requirements
func isValidPassword() -> Bool {
let pwRegEx = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]{8,}$"
let pwRegEx = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[d$@$!%*?&#])[A-Za-z\\dd$@$!%*?&#]{8,}"
let pwResult = NSPredicate(format:"SELF MATCHES %@", pwRegEx)
return pwResult.evaluate(with: self)
}
Expand Down

0 comments on commit a9a8a2f

Please sign in to comment.