Latest 0.1.9
License MIT
Platforms ios 8.4



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

pod "Valide"


From your ViewController set up everything first. Start with the validation names for the fields.

struct ValidationNames {
    static let nameField: String = "nameField"
    static let emailField: String = "emailField"
    static let nonEmptyField: String = "nonEmptyField"

Set up the rules you need. (You can create your own rules as well). Fields can have multiple rules to adhere to.

let requiredRule = RequiredRule()
let emailRule = EmailRule()
let emptyFieldRule = NonEmptyFieldRule()

let minCharsRule = MinCharsRule()
minCharsRule.minChars = 3

let maxCharsRule = MaxCharsRule()
maxCharsRule.maxChars = 50

Set validation name to field and add rules: = ValidationNames.nameField

self.emailField.validationName = ValidationNames.emailField

self.nonEmptyField.validationName = ValidationNames.nonEmptyField

When handling validation, usually by pressing a button, call the validate() method. This returns a closure with a success and error.

Upon receiving an error, the name of the field is returned as well as the error defined in the *Rule file. These can also be customised to your liking.{
        print("namefield validates")
    }, error: { (validationName, error) -> () in
        print("(validationName) handle: (error)")

        print("emailField validates")
    }, error: { (validationName, error) -> () in
        print("(validationName) handle: (error)")

        print("nonEmptyField validates")
    }, error: { (validationName, error) -> () in
        print("(validationName) handle: (error)")

For now; start with validating of the last element in your UI. So the last validation you code, is the first element on screen. I have not found a better way to do this. (If you do – please let me know)

You can then check the .isValid() on the field you are validating. This returns a tuple with three properties.

func isValid() -> (isValid:Bool, validationName: String, error: String?)

So then you can check self.nonEmptyField.isValid().isValid property.

if self.nonEmptyField.isValid().isValid {
    print("Field validates!")
    // Do something...


Sidney de Koning, [email protected]


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

Latest podspec

    "name": "Valide",
    "version": "0.1.9",
    "summary": "Something that helps you with the validity of the content of UITextFields by adding rules to them.",
    "description": "I needed a simple way of validating user input, so one afternoon I wrote this. Small, simple and to the point. It helps you with the validity of the content of UITextFields by adding rules to them. These rules can also be defined by you. Most common rules are shipped along the validation classes.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Sidney de Koning": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.9"
    "platforms": {
        "ios": "8.4"
    "source_files": "Valide/Classes/**/*"

Pin It on Pinterest

Share This