Vapor Documentation Beta

Structure Validator

public struct Validator<T: Decodable>

Initializers

init(validate:​)

public init(validate: @escaping (_ data: T) -> ValidatorResult)

Properties

validate

let validate: (_ data: T) -> ValidatorResult

valid

var valid: Validator<T>

Validates nothing. Can be used as placeholder to validate successful decoding

Methods

`case`(of:​)

public static func `case`<E>(of enum: E.Type) -> Validator<T> where E: RawRepresentable & CaseIterable, E.RawValue == T, T: CustomStringConvertible

Validates that the data can be converted to a value of an enum type with iterable cases.