Latest 2.0
Homepage https://github.com/dk53/ElValidator
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

Usage

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

Requirements

Require iOS 8 minimum.

Latest Swift 4 Version

2.0

Latest Swift 3 Version

1.1.2

Installation

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

pod "ElValidator"

Author

Victor Carmouze, [email protected]

Screenshot

Exemple

Exemple

Exemple

Usage

Basic usage

You must use TextFieldValidator who unherited UITextField to add validators.

var textField: TextFieldValidator

Then simply add the validators you likes.

textField.delegate = self
textField.add(validator: LenghtValidator(validationEvent: .validationPerCharacter, max: 10))
textField.validationBlock = validationBlock

Then you use the validation block to manage feedbacks

var validationBlock:((_: [Error]) -> Void)?

validationBlock = { [weak self] (errors: [Error]) -> Void in
    if let error = errors.first {
        print(error)
        self?.activeTextField?.textColor = .red;
    } else {
        self?.activeTextField?.textColor = .green
    }
}

Validators

A bunch of validators are included with the framework

  • Date validator
  • Lenght validator
  • Regex validator
  • List validator

Parameters

You can use two events to call your validation block

  • validationAtEnd
  • validationPerCharacter

Whom are passed to the validator.

You can additionate them with validationAllowBadCharacters who will block the user entry if one character is bad -ie: who type a numeric character instead of a decimal one-.

Adding validators

You can add any validators you like by subclassing the Validator class and overriding the validate method.

License

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

Latest podspec

{
    "name": "ElValidator",
    "version": "2.0",
    "summary": "A simple plugin to help you validate textfield entries",
    "description": "ElValidator Helps you controle yours UITextField user entriesn by validating them.n You can add multiples validators to a UITextfield :n- Date Validatorn- Lenght Validatorn- Regexn- ...",
    "homepage": "https://github.com/dk53/ElValidator",
    "license": "MIT",
    "authors": {
        "Victor Carmouze": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dk53/ElValidator.git",
        "tag": "2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This