AsyncConstraintSet

public struct AsyncConstraintSet<T>

A generic collection of AsyncConstraints on which an input can be validated on.

  • Returns the number of constraints in collection

    Declaration

    Swift

    public var count: Int { get }
  • Create a new AsyncConstraintSet instance

    Declaration

    Swift

    public init()
  • Create a new AsyncConstraintSet instance populated with a predefined list of AsyncConstraints

    Declaration

    Swift

    public init<C>(constraints: [C]) where T == C.InputType, C : AsyncConstraint

    Parameters

    constraints

    [AsyncConstraint]

  • Create a new AsyncConstraintSet instance populated with a unsized list of AsyncConstraints

    Declaration

    Swift

    public init<C>(constraints: C...) where T == C.InputType, C : AsyncConstraint

    Parameters

    constraints

    [AsyncConstraint]

  • Asynchronous evaluates the input on all AsyncConstraints until the first fails.

    Declaration

    Swift

    public func evaluateAny(input:T, queue: DispatchQueue = .main, 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 Result parameter:

    result

    .valid if the input is valid, .invalid containing the Error registered with the failing AsyncConstraint otherwise.

  • Asynchronous evaluates the input on all AsyncConstraints in the collection.

    Declaration

    Swift

    public func evaluateAll(input:T, queue: DispatchQueue = .main, 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 Array<Result> parameter:

    result

    An array of Result elements, indicating the evaluation result of each AsyncConstraint in collection.