iOS Validation Library

Related tags

Form Honour
Overview

Honour

Language License Version

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.

Usage

Single Validation

let username = "jeanpimentel"
Lowercase().validate(username) // true

Chained Validation

It is possible to use validators in a chain.

let v = Validator.addRule(Lowercase()).addRule(NoWhitespace()).addRule(Length(min: 3, max: 60))
v.validate("jeanpimentel") // true

Syntax sugar

It 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") // true

Granularity control

We have 3 validation methods

  • validate() - returns true or false
  • assert() - returns a tuple with true/false and all errors, if any.
  • check() - returns a tuple with true/false and the first error, if any.

Validate

func validate(value: AnyObject) -> Bool
let validator = Validator().addRule(Uppercase()).addRule(StartsWith("J"))
validator.validate("JEAN") // true
validator.validate("PIMENTEL") // false

Assert

func 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")]

Check

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")

Installation

Package is available on CocoaPods. See the "Using CocoaPods" guide for more information.

use_frameworks!
platform :ios, '7.0'
pod 'Honour', '~> 1.1.1'

Requirements

Honour Version Minimum iOS Target Notes
1.1.1 iOS 7 Swift 1.2 (Xcode 6.3) is required.

Contributing

  • 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.

    1. Fork it!
    2. Create your feature branch: git checkout -b my-new-feature
    3. Commit your changes: git commit -am 'Add some feature'
    4. Push to the branch: git push origin my-new-feature
    5. Submit a pull request

Validators

Always a working in progress...

Available now:

Localized validators

  • Brazil (BR)

License

Honour is released under the MIT license. See LICENSE for details.

You might also like...
 SwiftyFORM is a lightweight iOS framework for creating forms
SwiftyFORM is a lightweight iOS framework for creating forms

SwiftyFORM is a lightweight iOS framework for creating forms Because form code is hard to write, hard to read, hard to reason about. Has a

The most flexible and powerful way to build a form on iOS
The most flexible and powerful way to build a form on iOS

The most flexible and powerful way to build a form on iOS. Form came out from our need to have a form that could share logic between our iOS apps and

Declarative form building framework for iOS
Declarative form building framework for iOS

Formalist Swift framework for building forms on iOS Formalist is a Swift framework for building forms on iOS using a simple, declarative, and readable

Boring-example - Using boring crate from iOS application

BoringSSL example Using boring crate from iOS application. Checkout git clone gi

GrouponHeader - iOS TableView Header Animation, Swift/UIKit
GrouponHeader - iOS TableView Header Animation, Swift/UIKit

GrouponHeader Description: iOS TableView Header Animation Technology: Swift, UIK

SherlockForms - An elegant SwiftUI Form builder to create a searchable Settings and DebugMenu screens for iOS
SherlockForms - An elegant SwiftUI Form builder to create a searchable Settings and DebugMenu screens for iOS

🕵️‍♂️ SherlockForms What one man can invent Settings UI, another can discover i

Meet CRRulerControl - Customizable Control for iOS
Meet CRRulerControl - Customizable Control for iOS

Customizable component, created by Cleveroad iOS developers, is aimed at turning a simple ruler into a handy and smart instrument

iOS validation framework with form validation support

ATGValidator ATGValidator is a validation framework written to address most common issues faced while verifying user input data. You can use it to val

iOS Validation Library

Honour Validation library for iOS inspired by Respect/Validation. Validator.mustBe(Uppercase()).andMust(StartsWith("F")).validate("FOOBAR") ❗ If you w

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.
SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations. Objective Build a stan

Swift Validator is a rule-based validation library for Swift.
Swift Validator is a rule-based validation library for Swift.

Swift Validator is a rule-based validation library for Swift. Core Concepts UITextField + [Rule] + (and optional error UILabel) go into

🚦 Validation library depends on SwiftUI & Combine. Reactive and fully customizable.

🚦 Validation library depends on SwiftUI & Combine. Reactive and fully customizable.

A rule-based validation library for Swift
A rule-based validation library for Swift

SwiftValidator Swift Validator is a rule-based validation library for Swift. Core Concepts UITextField + [Rule] + (and optional error UILabel) go into

String (and more) validation for iOS

Swift Validators 🔶 String validation for iOS. Contents Installation Walkthrough Usage Available validators License ReactiveSwift + SwiftValidators Wa

Drop in user input validation for your iOS apps.
Drop in user input validation for your iOS apps.

Validator Validator is a user input validation library written in Swift. It's comprehensive, designed for extension, and leaves the UI up to you. Here

A modal passcode input and validation view controller for iOS
A modal passcode input and validation view controller for iOS

TOPasscodeViewController A modal passcode input and validation view controller for iOS. TOPasscodeViewController is an open-source UIViewController su

String (and more) validation for iOS

Swift Validators 🔶 String validation for iOS. Contents Installation Walkthrough Usage Available validators License ReactiveSwift + SwiftValidators Wa

MMVMi: A Validation Model for MVC and MVVM Design Patterns in iOS Applications

MMVMi MMVMi: A Validation Model for MVC and MVVM Design Patterns in iOS Applications Motivation Design patterns have gained popularity as they provide

APValidators - Codeless solution for form validation in iOS!
APValidators - Codeless solution for form validation in iOS!

APValidators is a codeless solution for form validation. Just connect everything right in Interface Builder and you're done. Supports really complex and extendable forms by allowing to connect validators in tree.

Comments
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
  • Crash with iOS9

    Crash with iOS9

    Hey, thanks for the great library! It worked like a charm until today when I updated to iOS 9. My app is crashing with the following log output:

    dyld: Library not loaded: @rpath/Honour.framework/Honour
      Referenced from: /private/var/mobile/Containers/Bundle/Application/6834122C-6D06-464B-B2C4-375E8890F3C0/highfive.app/highfive
      Reason: no suitable image found.  Did find:
        /private/var/mobile/Containers/Bundle/Application/6834122C-6D06-464B-B2C4-375E8890F3C0/highfive.app/Frameworks/Honour.framework/Honour: mach-o, but wrong architecture
        /private/var/mobile/Containers/Bundle/Application/6834122C-6D06-464B-B2C4-375E8890F3C0/highfive.app/Frameworks/Honour.framework/Honour: mach-o, but wrong architecture
        /private/var/mobile/Containers/Bundle/Application/6834122C-6D06-464B-B2C4-375E8890F3C0/highfive.app/Frameworks/Honour.framework/Honour: mach-o, but wrong architecture
    

    I tried removing the app and rebuilding, but nothing seems to help.

    Any ideas? Thanks.

    opened by zdesiree 4
Owner
Jean Pimentel
Staff Engineer
Jean Pimentel
A rule-based validation library for Swift

SwiftValidator Swift Validator is a rule-based validation library for Swift. Core Concepts UITextField + [Rule] + (and optional error UILabel) go into

null 1.4k Dec 29, 2022
APValidators - Codeless solution for form validation in iOS!

APValidators is a codeless solution for form validation. Just connect everything right in Interface Builder and you're done. Supports really complex and extendable forms by allowing to connect validators in tree.

Alty 131 Aug 16, 2022
Custom Field component with validation for creating easier form-like UI from interface builder.

#YALField Custom Field component with validation for creating easier form-like UI from interface builder. ##Example Project To run the example project

Yalantis 476 Sep 1, 2022
Declarative data validation framework, written in Swift

Peppermint Introduction Requirements Installation Swift Package Manager Usage Examples Predicates Constraints Predicate Constraint Compound Constraint

iOS NSAgora 43 Nov 22, 2022
XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C.

XLForm By XMARTLABS. If you are working in Swift then you should have a look at Eureka, a complete re-design of XLForm in Swift and with more features

xmartlabs 5.8k Jan 6, 2023
Carbon🚴 A declarative library for building component-based user interfaces in UITableView and UICollectionView.

A declarative library for building component-based user interfaces in UITableView and UICollectionView. Declarative Component-Based Non-Destructive Pr

Ryo Aoyama 1.2k Jan 5, 2023
Former is a fully customizable Swift library for easy creating UITableView based form.

Former is a fully customizable Swift library for easy creating UITableView based form. Submitting Issues Click HERE to get started with filing a bug r

Ryo Aoyama 1.3k Dec 27, 2022
ObjectForm - a simple yet powerful library to build form for your class models.

ObjectForm A simple yet powerful library to build form for your class models. Motivations I found most form libraries for swift are too complicated to

jakehao 175 Nov 2, 2022
SwiftForms is a small and lightweight library written in Swift that allows you to easily create forms.

SwiftForms is a powerful and extremely flexible library written in Swift that allows to create forms by just defining them in a couple of lines. It also provides the ability to customize cells appearance, use custom cells and define your own selector controllers.

Miguel Ángel Ortuño 1.3k Dec 27, 2022
Elegant iOS form builder in Swift

Made with ❤️ by XMARTLABS. This is the re-creation of XLForm in Swift. 简体中文 Overview Contents Requirements Usage How to create a Form Getting row valu

xmartlabs 11.6k Jan 1, 2023