ResponseValidator

public struct ResponseValidator<Body, Error> where Error : Error

A value type used to validate a RequestResponse

Initializers

  • Create a ResponseValidator

    Declaration

    Swift

    public init(_ handler: @escaping Handler)

    Parameters

    handler

    The closure used to validate

API

  • Specialized RequestResponse that this validator can validate

    Declaration

    Swift

    public typealias Response = RequestResponse<Body>
  • Closure used to validate responses

    Declaration

    Swift

    public typealias Handler = (Response) -> Result<Response, Error>
  • The validation handler

    Declaration

    Swift

    public let validate: Handler
  • An unsafe response validator, which never returns an error, regardless of the content of the response

    Declaration

    Swift

    static var unsafe: `Self` { get }

Available where Error == HTTPError

  • The default response validator for HTTPError types, which returns an error based on the status code

    Declaration

    Swift

    static var `default`: `Self` { get }

Available where Error == NoError

  • Undocumented

    Declaration

    Swift

    static var `default`: `Self` { get }