Skip to content

Instantly share code, notes, and snippets.

@bleft
Created February 28, 2019 12:20
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 bleft/4fb6adf9711f7014b33a8d8aad023cf9 to your computer and use it in GitHub Desktop.
Save bleft/4fb6adf9711f7014b33a8d8aad023cf9 to your computer and use it in GitHub Desktop.
check for valid email
extension String {
var isValidEmail: Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment