Skip to content

amitcse6/ASValidator

Repository files navigation

ASValidator

CI Status Version License Platform

Screenshots

ASValidator Screenshots

Example 1:

// Import
import SValidator

// Add A Validation
let svalidator = ASValidator()
textField.register(svalidator: validator, defaultErrorMsg: nil, rules: [ASVRequiredRule(nil), ASVMinLengthRule(2), ASVMaxLengthRule(5, nil)])

// Validation Check
let validate = asValidator.apply()
if let validate = validate, validate.isValid() {
    // MARK: - Validation Success
}else{
    // MARK: - Validation Fail
}

Example 2: for Effeciently Use

textField.addField(svalidator: svalidator, defaultErrorMsg: nil, rules: [ASVRequiredRule(errorMsg: nil)])

extension UITextField {
    func addField(svalidator: ASValidator?, defaultErrorMsg: String?, rules: [ASVRule]?) {
        register(
            svalidator: svalidator,
            field: self,
            errorLabel: nil,
            errorBorderView: self,
            errorBorderColor: .red,
            normalBorderColor: .gray,
            defaultErrorMsg: defaultErrorMsg,
            borderWidth: 1.0,
            rules: rules
        )
    }
}

Validation Rule

ASVRequiredRule(nil)
ASVMinLengthRule(2)
ASVMaxLengthRule(5, nil)
...

Requirements

Installation

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

pod 'ASValidator'

Author

Amit Mondol, amitpstu1@gmail.com

License

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