Created
January 7, 2020 00:10
-
-
Save adam-zethraeus/b83a00d473895073eff3223220dc18d6 to your computer and use it in GitHub Desktop.
An excerpt of key functional from https://gist.github.com/zethraeus/34d2aa882c106d8f44ecda6a976361db#file-badonboardingmanager-swift
This file contains 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
private func validatePassword() { | |
self.passwordIsValid = false | |
self.passwordIssue = nil | |
guard let username = self.username, | |
let email = self.email, | |
let phoneNumber = self.phoneNumber, | |
let password = self.password | |
else { | |
return | |
} | |
if password.count < 10 { | |
self.passwordIssue = .tooShort | |
} | |
if password.contains(username) { | |
self.passwordIssue = .containsUsername | |
} | |
if password.contains(email) { | |
self.passwordIssue = .containsEmail | |
} | |
if password.contains(phoneNumber) { | |
self.passwordIssue = .containsPhoneNumber | |
} | |
if !passwordContainsAtLeastOneNumber() { | |
self.passwordIssue = .noNumbers | |
} | |
if !passwordContainsAtLeastOneSpecialCharacter() { | |
self.passwordIssue = .noSpecialCharacters | |
} | |
self.passwordIsValid = true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment