dalu93 / validation-kit

Lightweight framework for input validation written in Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Validation Kit · Validation Components


Validation Kit

travis-status codecov-status carthage-compatible license twitter

Introduction

Validation Kit is designed to be a lightweight framework specialised in user data validation, such as email format, input length or passwords matching.

At the core of this project are the following principles:

  • Separation of concerns
  • Availability on all platforms
  • Open to extensibility

Separation of concerns

Think of Validation Kit as to an adjustable wrench more than to a Swiss knife. With this idea in mind, the kit is composed from a small set of protocols, classes and structs than ca be easily used to fit your project needs.

All platforms availability

Since validation can take place at many levels, Validation Kit was designed to support iOS, macOS, tvOS, watchOS and native swift projects, such as server apps.

Open to extensibility

Every project is uniq in it's challenges and it's great when we can focus on solving them instead on focusing on boiler plate tasks. While Validation Kit is compact and offers all you need to build validation around your project needs, we created Validation Components to extends it by adding the common validations that most of the projects can benefits of. This includes validation predicates for email, required fields, password matching, url and many other.

Installation

Carthage

The full documentation on how to install and use Carthage is available on their official github page.

To use the latest stable version, add this to your Cartfile:

github "nsagora/validation-kit" 

To use a certain version, add this to your Cartfile:

github "nsagora/validation-kit" >= 0.1.0 

To use the latest version in development, add this to your Cartfile:

github "nsagora/validation-kit" "develop" 

Concepts

ValidationPredicate

The ValidationPredicate represents the core protocol and has the role to evaluate if an input matches on a given predicate.

Out of the box, ValidationKit brings the following predicates, which allow the developers to construct their specific predicates:

  • RegexValidationPredicate
  • BlockValidationPredicate

For more advanced or complex predicates the developers can extend the ValidationPredicate to fit the project needs.

ValidationConstraint

A ValidationConstraint represents a structure that link a ValidationPredicate with a custom message, useful for user feedback.

Validator

A Validator represents a collection of constraints and allows the evaluation to be made on:

  • any of the constraints
  • all constraints

To provide context, a Validator allows to constrain an input as being required and as being a valid email.

Credits and references

The project was been inspired from other open source projects and they worth to be mentioned below for reference:

About

Lightweight framework for input validation written in Swift

License:Apache License 2.0


Languages

Language:Swift 90.9%Language:Ruby 6.9%Language:Objective-C 2.3%