A UITextField that easy validate text of UITextField
To run the example project, clone the repo, and run pod install
from the Example directory first.
- demo.gif
- can change success image, error image
- sample code
@IBOutlet weak var nameTextField: ValidationTextField!
@IBOutlet weak var passwordTextField: ValidationTextField!
@IBOutlet weak var passwordConfirmTextField: ValidationTextField!
@IBOutlet weak var emailTextField: ValidationTextField!
override func viewDidLoad() {
super.viewDidLoad()
nameTextField.validCondition = {$0.count > 5}
emailTextField.validCondition = {$0.count > 5 && $0.contains("@")}
passwordTextField.validCondition = {$0.count > 8}
passwordConfirmTextField.validCondition = {
guard let password = self.passwordTextField.text else {
return false
}
return $0 == password
}
}
ValidationTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ValidationTextField'
Apache License Version 2.0