Skip to content

Instantly share code, notes, and snippets.

@imjhk03
Created December 20, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjhk03/96e5ad083d49107ef87f9f4f3a0729b9 to your computer and use it in GitHub Desktop.
Save imjhk03/96e5ad083d49107ef87f9f4f3a0729b9 to your computer and use it in GitHub Desktop.
String+Extension
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