Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Last active July 14, 2017 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/987ce4660dd5eda10ae5ee58f60240d3 to your computer and use it in GitHub Desktop.
Save PaulRBerg/987ce4660dd5eda10ae5ee58f60240d3 to your computer and use it in GitHub Desktop.
AdPacer - APLoginData
import UIKit
class APLoginData {
var dummy: String?
}
extension APLoginViewController {
/**
* Checks to see if the entered profile data is valid.
*/
func isDataValid() -> Bool {
/**
* Email requirements.
*/
if !emailTextField.text!.isEmail() {
APAlert.top(NSLocalizedString("Invalid email address", comment: ""))
return false
}
/**
* Password requirements.
*/
// We do not allow less than 8 characters and more than 100.
if passwordTextField.text!.characters.count < 8 || passwordTextField.text!.characters.count > 100 {
APAlert.top(NSLocalizedString("Password must have between 8 and 100 letters", comment: ""))
return false
}
// We do not allow spaces at the beginning and at the end of the string.
if passwordTextField.text![0] == " " || passwordTextField.text![passwordTextField.text!.characters.count-1] == " " {
APAlert.top(NSLocalizedString("Password's first and last char cannot be a space", comment: ""))
return false
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment