Vapor Documentation Beta

Protocol Validatable

public protocol Validatable

Capable of being validated. Conformance adds a throwing validate() method.

struct User: Validatable {
    var name: String
    var age: Int

    static func validations() -> [Validation] {
        [Validation(key: "name", validator: .count(5...) && .alphanumeric)]
    }
}

Requirements

validations(_:​)

static func validations(_ validations: inout Validations)