Swiftpack.co - Package - smbhuin/Validator

Validator

Rule based validation library for swift.

Platform Carthage Compatible SPM Compatible LICENSE

Features

  • Rule based validation
  • Class/Struct validation
  • Validatable/Validator chaining
  • Linux Compatible (Can be used with Kitura, Vapor, Perfect)

iPhone Screenshot

Screenshot

Installation

To install Validator, add it as a submodule to your project (on the top level project directory):

git submodule add https://github.com/smbhuin/Validator.git

Carthage

You can use Carthage. Specify in Cartfile:

github "smbhuin/Validator"

Run carthage to build the framework and drag the built Validator.framework into your Xcode project. Follow build instructions.

CocoaPods

You can use CocoaPods.

platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
pod 'AnyValidator'
end

or for newest version from specified branch of code:

pod 'AnyValidator', :git => "https://github.com/smbhuin/Validator", :branch => "master"

Swift Package Manager

You can use Swift Package Manager and specify dependency in Package.swift by adding this:

dependencies: [
    .package(url: "https://github.com/smbhuin/Validator.git", from: "1.0.5")
]

or more strict

dependencies: [
    .package(url: "https://github.com/smbhuin/Validator.git", .exact("1.0.5"))
]

Usage

import Validator // If you are using Cocoapod then import AnyValidator

let v = Validator()
v.add(name: "Email", value: email, rules: [.required, .email])
v.add(name: "Name", value: name, rules: [.required, .fullName])
v.add(name: "Subject", value: subject, rules: [.required, .length(min: 10, max: 200)])
v.add(name: "Message", value: message, rules: [.required, .length(min: 10, max: 2000)])
let (valid, validatable, error) = v.validate()

API documentation

For more information visit our API reference.

License

This library is licensed under MIT. Full license text is available in LICENSE.

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0

Releases

1.0.5 - Dec 12, 2019

Updated

  • ArrayRule updated.

1.0.4 - Jul 31, 2019

Updated

  • Package restructured.
  • XCode Project Config Updated.
  • Cocoapod Spec Updated.

Renamed

  • var ISBN renamed to isbn in ISBNRule.
  • var IPV4 renamed to ipv4 in IPV4Rule.
  • var iso8601date renamed to iso8601Date in ISO8601DateRule.

1.0.3 - Jul 28, 2019

Updated

  • Fixes for cocoapod.

1.0.2 - Jul 28, 2019

Updated

  • Fixes for cocoapod.

1.0.1 - Jul 28, 2019

Updated

  • Validator functions return named touples now.