Created
May 21, 2019 14:21
-
-
Save saru2020/cb934031c04d8a9265dff63cc79f761a to your computer and use it in GitHub Desktop.
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
| extension String { | |
| /// Used to validate if the given string is valid email or not | |
| /// | |
| /// - Returns: Boolean indicating if the string is valid email or not | |
| func isValidEmail() -> Bool { | |
| let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}" | |
| let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx) | |
| print("emailTest.evaluate(with: self): \(emailTest.evaluate(with: self))") | |
| return emailTest.evaluate(with: self) | |
| } | |
| /// Used to validate if the given string matches the password requirements | |
| /// | |
| /// - Returns: Boolean indicating the comparison result | |
| func isValidPassword() -> Bool { | |
| print("self.count >= 6: \(self.count >= 6)") | |
| return self.count >= 6 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment