Latest 0.0.1
Homepage https://github.com/fromkk/Valy
License MIT
Platforms ios 8.0
Authors

Valy

Valy is string validation library with Swift 3.

Required

  • Swift 3
  • Xcode 8
  • iOS 8~ / watchOS 2~ / tvOS 8~ / macOS 10.16~
  • Carthage or Cocoapods

Install

with Carthage

Add github "fromkk/Valy" to Cartfile and execute carthage update command on your terminal in project directory.

Add Carthage/Build/{Platform}/Valy.framework to Link Binary with Libralies in you project.
If you doesn’t use Carthage, add New Run Script Phase and input /usr/local/bin/carthage copy-frameworks in Build Phases tab.
Add $(SRCROOT)/Carthage/Build/{Platform}/Valy.framework to Input Files.

with Cocoapods

Add pod 'Valy' to Podfile and run pod install command on your terminal in project directory.
Open {YourProject}.xcworkspace file.

Usage

Basic

import Valy

let value: String? = nil
let result = Valy.factory(rules: [ValyRule.required]).run(with: value)
switch result {
case .failure(let rule):
    switch rule {
    case ValyRule.required:
        print("value ((value)) is required...")
    default:
        break
    }
default:
    print("value ((value)) is successed!")
    break
}

Add rule

Valy.factory().add(rule: ValyRule.required).add(rule: ValyRule.maxLength(10)).run(with: value)

Text Field

let textField = VLTextField(frame: frame)
textField.add(rules: [
    ValyRule.required,
    ValyRule.maxLength(30)
])
textField.ovserveValidation { (status, result) in
    switch result {
    case .success:
        print("textField success")
    case .failure(let rule):
        print("failed (rule)")
    }
}

CustomRule

enum CustomValidatorRule: AnyValidatorRule {
    case email
    func run(with value: String?) -> Bool {
        switch self {
        case .email:
            return doYourEmailValidation()
        }
    }
}

Valy.factory().add(rule: CustomValidatorRule.email).run(with: value)

Latest podspec

{
    "name": "Valy",
    "version": "0.0.1",
    "summary": "Valy is validation library with Swift 3",
    "description": "# ValynnValy is string validation library with Swift 3.nn# Requirednn- Swift 3n- Xcode 8n- iOS 8~ / watchOS 2~ / tvOS 8~ / macOS 10.16~",
    "homepage": "https://github.com/fromkk/Valy",
    "license": "MIT",
    "authors": {
        "fromkk": "[email protected]"
    },
    "social_media_url": "http://twitter.com/fromkk",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/fromkk/Valy.git",
        "tag": "0.0.1"
    },
    "source_files": "Sources/*.swift",
    "pushed_with_swift_version": "3.0.1"
}

Pin It on Pinterest

Share This