Skip to content

Instantly share code, notes, and snippets.

@tularovbeslan
Created July 9, 2017 19:54
Show Gist options
  • Save tularovbeslan/f736c6291aa107f8f1a4ec05461c4803 to your computer and use it in GitHub Desktop.
Save tularovbeslan/f736c6291aa107f8f1a4ec05461c4803 to your computer and use it in GitHub Desktop.
Email and password validate
func isValidEmail(email: String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
let validatedEmail = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return validatedEmail.evaluate(with: email)
}
func isValidPassword(password: String) -> Bool {
let passwordRegEx = "[A-Z0-9a-z]{5,}"
let validatedPassword = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return validatedPassword.evaluate(with: password)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment