AsyncConstraint

public protocol AsyncConstraint<InputType, ErrorType>

The AsyncConstraint protocol is used to define the structure that must be implemented by concrete asynchronous constraints.

  • A type that provides information about what kind of values the constraint can be evaluated with.

    Declaration

    Swift

    associatedtype InputType
  • An error type that provides information about why the evaluation failed.

    Declaration

    Swift

    associatedtype ErrorType : Error
  • Asynchronous evaluates the input on the provided queue.

    Declaration

    Swift

    @available(*, deprecated, renamed: "evaluate(with:﹚")
    func evaluate(with input: InputType, queue: DispatchQueue, completionHandler: @escaping (_ result: Result<Void, Summary<ErrorType>>) -> Void)

    Parameters

    input

    The input to be validated.

    queue

    The queue on which the completion handler is executed.

    completionHandler

    The completion handler to call when the evaluation is complete. It takes a Bool parameter:

    result

    .success if the input is valid, .failure containing the Summary of the failing Constraints otherwise.

  • evaluate(with:) Asynchronous

    Asynchronous evaluates the input against the receiver.

    Declaration

    Swift

    func evaluate(with input: InputType) async -> Result<Void, Summary<ErrorType>>

    Parameters

    input

    The input to be validated.

    Return Value

    .success if the input is valid,.failure containing the Summary of the failing Constraints otherwise.

  • check(_:) Default implementation, asynchronous

    Asynchronous evaluates the input against the receiver. When the evaluation is successful, it return the input, otherwise it throws the Summary of the failing Constraint.

    Throws

    The Summary of the failing Constraints when the validation fails.

    Default Implementation

    Asynchronous evaluates the input against the receiver. When the evaluation is successful, it return the input, otherwise it throws the Summary of the failing Constraint.

    Throws

    The Summary of the failing Constraints when the validation fails.

    Declaration

    Swift

    func check(_ input: InputType) async throws -> InputType

    Parameters

    input

    The input to be validated.

    Return Value

    The input when the validation is successful.