Latest 1.0.2
License BSD
Platforms ios 8.0, tvos 9.0
Dependencies LocalizationToolkit

Swift Version
Build Status
CocoaPods Compatible
Carthage Compatible

Roadblock, a simple way to check forms verifications.



To install Roadblock with CocoaPods, add the following lines to your Podfile.

source ''
platform :ios, '9.0'

pod 'Roadblock'


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Roadblock into your Xcode project using Carthage, specify it in your Cartfile:

github 'Digipolitan/roadblock' ~> 1.0

Run carthage update to build the framework and drag the built Roadblock.framework into your Xcode project.

The Basics

First to catch errors you need to add the following keys to your Localizable.string file

"errors.validator.required" = "Missing required field";
"" = "Invalid email";
"errors.validator.min_length" = "Minimum %1$d characters";
"errors.validator.max_length" = "Maximum de %1$d characters";

After that, you need to implement the FormDelegate protocol

extension ViewController: FormDelegate {

    func formDidSubmit(_ form: Form) {

Then you can register the form on your viewDidLoad() method like following

@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
public var form: Form!
private var formTextFieldChainable: FormTextFieldDelegateChainable?

override func viewDidLoad() {

       self.form = Form(fields: [
                 target: self.emailTextField,
                 name: "email",
                 transformer:, FieldTransformers.emptyIsNil())),
           .init(identifier: Fields.password,
                 target: self.passwordTextField,
                 name: "password",
                 transformer:, FieldTransformers.emptyIsNil()))
           ], delegate: self)

       let formTextFieldChainable = FormTextFieldDelegateChainable(form: self.form)
       self.emailTextField.delegate = formTextFieldChainable
       self.passwordTextField.delegate = formTextFieldChainable
       self.formTextFieldChainable = formTextFieldChainable

Then you can handle the forms errors on youre @IBAction function

@IBAction func validateButtonClicked() {
    do {
        try self.form.validate()
    } catch {
        if let err = error as? FormError {
            let alertController = UIAlertController(title: "Error", message:
                    err.localizedDescription, preferredStyle: UIAlertControllerStyle.alert)
            alertController.addAction(UIAlertAction(title: "Dismiss",style: UIAlertActionStyle.default, handler: nil))

            self.present(alertController, animated: true, completion: nil)


See for more details!

This project adheres to the Contributor Covenant Code of Conduct.
By participating, you are expected to uphold this code. Please report
unacceptable behavior to [email protected].


Roadblock is licensed under the BSD 3-Clause license.

Latest podspec

    "name": "Roadblock",
    "version": "1.0.2",
    "summary": "Roadblock is a simple way to check forms verifications",
    "homepage": "",
    "authors": "Digipolitan",
    "source": {
        "git": "",
        "tag": "v1.0.2"
    "license": {
        "type": "BSD",
        "file": "LICENSE"
    "source_files": "Sources/**/*.{swift,h}",
    "platforms": {
        "ios": "8.0",
        "tvos": "9.0"
    "swift_version": "4.2",
    "dependencies": {
        "LocalizationToolkit": [
            "~> 1.0"

Pin It on Pinterest

Share This