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
}
}
ValidateIt is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ValidateIt"
Juan Villalta, [email protected]
ValidateIt is available under the MIT license. See the LICENSE file for more info.