Created
July 9, 2017 19:54
-
-
Save tularovbeslan/f736c6291aa107f8f1a4ec05461c4803 to your computer and use it in GitHub Desktop.
Email and password validate
This file contains hidden or 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
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