Created
December 20, 2020 13:43
-
-
Save imjhk03/96e5ad083d49107ef87f9f4f3a0729b9 to your computer and use it in GitHub Desktop.
String+Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
var isValidEmail: Bool { | |
let emailFormat = "" | |
let emailPredicate = NSPredicate(format: "SELF MATCHES %@", emailFormat) | |
return emailPredicate.evaluate(with: self) | |
} | |
var isValidPassword: Bool { | |
//Regex restricts to 8 character minimum, 1 capital letter, 1 lowercase letter, 1 number | |
let passwordFormat = "" | |
let passwordPredicate = NSPredicate(format: "SELF MATCHES %@", passwordFormat) | |
return passwordPredicate.evaluate(with: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment