Constraint

public protocol Constraint : AsyncConstraint

The Constraint protocol is used to define the structre that must be implemented by concrete constraints.

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

    Declaration

    Swift

    associatedtype InputType
  • Evaluates the input against the receiver.

    Declaration

    Swift

    func evaluate(with input: InputType) -> Result

    Parameters

    input

    The input to be validated.

    Return Value

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

  • Asynchronous evaluates the input against the receiver.

    Declaration

    Swift

    public func evaluate(with input: InputType, 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.