ConditionedAsyncConstraint

public class ConditionedAsyncConstraint<T> : AsyncConstraint

A structrure that links an AsyncPredicate to an Error that describes why the predicate evaluation has failed.

  • Create a new ConditionedAsyncConstraint instance

    Declaration

    Swift

    public init<P>(predicate: P, error: Error) where T == P.InputType, P : AsyncPredicate

    Parameters

    predicate

    An AsyncPredicate to describes the evaluation rule.

    error

    An Error that describes why the evaluation has failed.

  • Create a new ConditionedAsyncConstraint instance

    Declaration

    Swift

    public init<P:AsyncPredicate>(predicate:P, error: @escaping (T)->Error) where P.InputType == T

    Parameters

    predicate

    An AsyncPredicate to describes the evaluation rule.

    error

    An generic closure that dynamically builds an Error to describe why the evaluation has failed.

  • Add a condition AsyncConstraint.

    Declaration

    Swift

    public func add<C>(condition: C) where T == C.InputType, C : AsyncConstraint

    Parameters

    constraint
  • Asynchronous evaluates the input on the Predicate.

    Declaration

    Swift

    public func evaluate(with input: T, queue: DispatchQueue, completionHandler: @escaping (_ result:Result) -> 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

    .valid if the input is valid, .invalid containing the Result.Summary of the failing Constraints otherwise.