Code Monkey home page Code Monkey logo

validation-components's Introduction

Validation Toolkit · Validation Components


Maintenance Status badge-support

Validation Components is now an integrated part of Validation Toolkit and we don't maintain it as a standalone framework anymore.

For more details on how you can empower data validation in your projects, checkout Validation Toolkit 😋.

Validation Components

badge-travis badge-codecov badge-carthage badge-license badge-twitter badge-version badge-validation-toolkit

  1. Introduction
  2. Requirements
  3. Installation
  4. Usage Examples
  5. Contribute
  6. Meta

Introduction

Validation Components extends the ValidationToolkit framework by offering a collection of common validation predicates that most of the projects can benefit of.

Requirements

  • iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 8.1+
  • Swift 3.0+

Installation

Please note that ValidationComponents requires ValidationToolkit.

Carthage

You can use Carthage to install ValidationComponents by adding it to your Cartfile:

github "nsagora/validation-components"

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

Setting up Carthage

Carthage is a decentralised 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

CocoaPods

You can use CocoaPods to install ValidationComponents by adding it to your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'YOUR_TARGET_NAME' do
	pod 'ValidationComponents'
end

Then, run the following command:

$ pod install

Note that this requires CocoaPods version 1.0.0, and your iOS deployment target to be at least 8.0.

Setting up CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

Swift Package Manager

You can use the Swift Package Manager to install ValidationComponents by adding it to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/nsagora/validation-components", majorVersion: 1),
    ]
)

Note that the Swift Package Manager is still in early design and development, for more information checkout its GitHub Page.

Manually

To use this library in your project manually you may:

  1. for Projects, just drag the Sources folder into the project tree
  2. for Workspaces, include the whole ValidationComponents.xcodeproj

Usage example

For a comprehensive list of examples try the ValidationComponents.playground:

  1. Download the repository locally on your machine
  2. Run carthage update to build the required version of ValidationToolkit
Setting up Carthage

Carthage is a decentralised 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
  1. Open ValidationComponents.workspace
  2. Build ValidationComponents iOS target
  3. Select the ValidationComponents playgrounds from the Project navigator.

Email Predicate

Use a EmailPredicate to evaluate if a given email address is syntactically valid.

import ValidationComponents

let predicate = EmailPredicate()
predicate.evaluate(with: "hello@") // returns false
predicate.evaluate(with: "[email protected]") // returns true
predicate.evaluate(with: "[email protected]") // returns true

URL Predicate

Use a URLPredicate to evaluate if a given URL is syntactically valid.

import ValidationComponents

let predicate = URLPredicate()
predicate.evaluate(with: "http://www.url.com") // returns true
predicate.evaluate(with: "http:\\www.url.com") // returns false

Pair Matching Predicate

Use a PairMatchingPredicate to evaluate if a given pair of values match.

import ValidationComponents

let predicate = PairMatchingPredicate()
predicate.evaluate(with: ("swift", "swift")) // returns true
predicate.evaluate(with: ("swift", "obj-c")) // returns false

Contribute

We would love you for the contribution to ValidationComponents, check the LICENSE file for more info.

Meta

This project developed and maintained by the members of iOS NSAgora, the community of iOS Developers of Iași, Romania.

Distributed under the MIT license. See LICENSE for more information.

https://github.com/nsagora/validation-components

validation-components's People

Contributors

alexcristea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.