Swiftpack.co - Package - smbhuin/SBValidator

SBValidator

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/SBValidator.git

Carthage

You can use Carthage. Specify in Cartfile:

github "smbhuin/SBValidator"

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

CocoaPods

You can use CocoaPods.

platform :ios, '10.0'
use_frameworks!

target 'MyApp' do
pod 'SBValidator'
end

or for newest version from specified branch of code:

pod 'SBValidator', :git => "https://github.com/smbhuin/SBValidator", :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/SBValidator.git", from: "2.0.0")
]

or more strict

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

Usage

import SBValidator

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

Dependencies

Used By

Total: 0

Releases

Release 2.0.0 - 2020-01-07 09:34:05

Renamed

  • Framework renamed.
  • Cocoapod framework renamed to SBValidator.

Release 1.0.5 - 2019-12-12 07:21:21

Updated

  • ArrayRule updated.

Release 1.0.4 - 2019-07-31 17:29:19

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.

Release 1.0.3 - 2019-07-28 09:15:35

Updated

  • Fixes for cocoapod.

Stable Release 1.0.2 - 2019-07-28 09:01:42

Updated

  • Fixes for cocoapod.

Stable Release 1.0.1 - 2019-07-28 07:45:22

Updated

  • Validator functions return named touples now.

Initial Release - 2019-07-27 18:48:58

  • Initial release of Validator.