Swiftpack.co - Package - vapor/validation

Github

link
Stars: 33
Help us keep the lights on

Dependencies

Releases

2.1.0 - Aug 9, 2018

New:

  • Added .url validator. (#28)
try validations.add(\.profilePictureURL, .url || .nil)
  • Added .empty validator. (#27)
try validations.add(\.preferedColors, !.empty)

2.0.0 - Apr 11, 2018

Validation 2.0 is here! 🎉 ✅ Extensible data validation library (name, email, etc)

Docs: https://docs.vapor.codes/3.0/validation/getting-started/

API Docs: https://api.vapor.codes/validation/latest/Validation

Milestone: 2.0.0


Changes since final release candidate:

Validation was in need of some love before the official release. The APIs have been streamlined quite a bit.

  • Validators are now accessed via leading-dot syntax instead of globally available types.
  • Validatable now requires a static function instead of a static property.
  • Validations are now generic.
  • ValidationData has been removed in favor of type-safe alternative.
  • Separate Range and Count validators.
  • New CharacterSet validator.

Here's an example of how the API looks now compared to previous release:

2.0.0

struct User: Validatable, Reflectable, Codable {
    var id: Int?
    var name: String
    var age: Int
    var email: String?

    static func validations() throws -> Validations<User> {
        var validations = Validations(User.self)
        try validations.add(\.name, .count(5...) && .alphanumeric)
        try validations.add(\.age, .range(18...))
        try validations.add(\.email, .email || .nil)
        return validations
    }
}

2.0.0-rc

struct User: Validatable, Reflectable, Codable {
    var id: Int?
    var name: String
    var age: Int
    var email: String?

    static var validations: Validations = [
        key(\.name): IsCount(5...) && IsAlphanumeric(),
        key(\.age): IsCount(18...),
        key(\.email): IsEmail() || IsNil()
    ]
}

2.0.0-rc.2.1 - Mar 22, 2018

New:

  • Use Core.Reflectable protocol.

Milestone

2.0.0-rc.2 - Mar 21, 2018

New:

  • Vapor is now running on Swift NIO!

Milestone

2.0.0-rc.1 - Feb 23, 2018