Skip to content

Instantly share code, notes, and snippets.

@pyxn
Created August 18, 2020 01:04
Show Gist options
  • Save pyxn/e0969033a53e50ed39739a43928fe349 to your computer and use it in GitHub Desktop.
Save pyxn/e0969033a53e50ed39739a43928fe349 to your computer and use it in GitHub Desktop.
import Foundation
extension String {
var isValidEmail: Bool {
let emailFormat: String = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailPredicate = NSPredicate(format: "SELF MATCHES %@", emailFormat)
return emailPredicate.evaluate(with: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment