Skip to content

devikkim/ValidationTextField

Repository files navigation

ValidationTextField

CI Status Version Platform

A UITextField that easy validate text of UITextField

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

  • demo.gif

Demo 

  • can change success image, error image

Demo 

  • 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
  }

}

Installation

ValidationTextField is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ValidationTextField'

Author

[email protected]

License

Apache License Version 2.0