Skip to content

Latest commit

 

History

History
81 lines (51 loc) · 2.23 KB

README.md

File metadata and controls

81 lines (51 loc) · 2.23 KB

ValidateIt

CI Status Version License Platform

Example

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

##Use

@IBAction func actValidate(_ sender: UIButton) {

        view.endEditing(true)

        validation.errors.removeAll()

        validation.required(txtFirstName)
        validation.required(txtLastName)
        
        if !txtLastName.text!.isEmpty {
            validation.lettersSpaceOnly(txtLastName)
        }
        
        validation.required(txtEmail)
        
        
        if !txtEmail.text!.isEmpty {
            validation.email(txtEmail)
        }

        validation.required(txtPassword)

        if !txtPassword.text!.isEmpty {
            validation.minLength(6, textField: txtPassword)
        }
        
        validation.required(txtConfirmPassword, msgError: "Confirm the password")
        
        if !txtPassword.text!.isEmpty && !txtConfirmPassword.text!.isEmpty {
            validation.textField(txtPassword, equalTotextField: txtConfirmPassword, msgError: "Passwords no match.")
        }

        print("\(self.classForCoder) \(#function) \(#line)- validation: \(validation.errors)")

        if validation.isValid() {

            lblErrors.text = " Validated "
            lblErrors.backgroundColor = .blue

        } else {

            lblErrors.text = validation.errors.joined(separator: "\n")
            lblErrors.backgroundColor = .red

        }
    }

Requirements

Installation

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

pod "ValidateIt"

Author

Juan Villalta, [email protected]

License

ValidateIt is available under the MIT license. See the LICENSE file for more info.