Swiftpack.co - Package - skelpo/Failable

Validation

A description of this package.

Github

link
Stars: 1
Help us keep the lights on

Dependencies

Used By

Total: 1

Releases

0.4.0 - Mar 28, 2019

Swift 5

Failable now works with Swift 5. chances are it doesn't work with Swift 4 anymore, but as they say, 'move fast and break things'.

0.2.0 - Dec 10, 2018

Failable Validation

Renamed the package to Failable so it doesn't conflict with the vapor/validation package.

0.1.0 - Dec 10, 2018

Check, Check, Check

Got the basics of the Failable type working. It lets you have a value with constrained values. Foe example, if you have a string that needs to be 256 characters or less, you can do this:

struct Length1028: LengthValidation {
    typealias Supported = String
    static var maxLength: Int { return 1028 }
}

var str = try Failable<String, Length1028>("Hello World")

Every time you set the value (using <~), the validations for its type are run and if they fail, you get an error:

try str <~ "This passes" // Success!
try str <~ String(repeating: "n", count: 257) // Fails