A validation library for Swift
Swift Shell Ruby Objective-C C++ C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ExValidator
ExValidatorExample
Source
.gitignore
ExValidator.podspec
LICENSE
README.md

README.md

ExValidator

CI Status Version License Platform

A validation library for Swift

Example

if "foo".validate([.Required]) {
    // should be true
}
struct Model {
    var name: String
    var age: Int

    init() {
        name = ""
        age = 0
    }
}

func validateData (data: Model) -> Bool {
    if data.name.validate([.Required]) &&
       data.age.validate([.Min(20)])
    {
        return true
    }

    return false
}

var data: Model = Model()
validateData(data) // should be false

data = Model()
data.name = "Name"
data.age = 20
validateData(data) // should be true

Rules

  • .Required
  • .Min(min :Int)
  • .Max(max :Int)

WIP

Multiple rules doesn't work yet.

License

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