CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Sep 2015 |
| SPMSupports SPM | ✗ |
Maintained by Jean Pimentel.
Validation library for iOS inspired by Respect/Validation.
Validator.mustBe(Uppercase()).andMust(StartsWith("F")).validate("FOOBAR")
If you want to use this library in Objective-C classes, check HonourBridge repo.
let username = "jeanpimentel"
Lowercase().validate(username) // trueIt is possible to use validators in a chain.
let v = Validator.addRule(Lowercase()).addRule(NoWhitespace()).addRule(Length(min: 3, max: 60))
v.validate("jeanpimentel") // trueIt is possible to use some syntax tricks to be highly expressive.
let v = Validator.mustHave(Length(min: 3, max: 60)).and(NoWhitespace()).andMustBe(Lowercase())
v.validate("jeanpimentel") // trueWe have 3 validation methods
validate() - returns true or falseassert() - returns a tuple with true/false and all errors, if any.check() - returns a tuple with true/false and the first error, if any.func validate(value: AnyObject) -> Boollet validator = Validator().addRule(Uppercase()).addRule(StartsWith("J"))
validator.validate("JEAN") // true
validator.validate("PIMENTEL") // falsefunc assert(value: AnyObject) -> (isValid: Bool, invalidRules: Array<Rule>)let validator = Validator().addRule(Uppercase()).addRule(StartsWith("J"))
let result = validator.assert("JEAN")
result.isValid // true
result.invalidRules // [] (empty)
let result = validator.assert("Jean")
result.isValid // false
result.invalidRules // [Uppercase()]
let result = validator.assert("Felipe")
result.isValid // false
result.invalidRules // [Uppercase(), StartsWith("J")]func check(value: AnyObject) -> (isValid: Bool, invalidRule: Rule?)let validator = Validator().addRule(Uppercase()).addRule(StartsWith("J"))
let result = validator.check("JEAN")
result.isValid // true
result.invalidRule // nil
let result = validator.check("Felipe")
result.isValid // false
result.invalidRule // Uppercase()
let result = validator.check("FELIPE")
result.isValid // false
result.invalidRule // StartsWith("J")Package is available on Cocoapods. See the “Using CocoaPods” guide for more information.
use_frameworks!
platform :ios, '7.0'
pod 'Honour', '~> 1.1.1'| Honour Version | Minimum iOS Target | Notes |
|---|---|---|
| 1.1.1 | iOS 7 | Swift 1.2 (Xcode 6.3) is required. |
If you found a bug, and can provide steps to reliably reproduce it, open an issue.
If you have a feature request, open an issue.
If you want to contribute, submit a pull request.
git checkout -b my-new-feature git commit -am 'Add some feature' git push origin my-new-feature Always a working in progress…
Available now:
Localized validators
Honour is released under the MIT license. See LICENSE for details.