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
instanceDeclaration
Swift
public init()
-
Create a new
AsyncConstraintSet
instance populated with a predefined list ofAsyncConstraints
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 ofAsyncConstraints
Declaration
Swift
public init<C>(constraints: C...) where T == C.InputType, C : AsyncConstraint
Parameters
constraints
[AsyncConstraint]
-
Adds a
AsyncConstraint
to the generic collection of constraints.Declaration
Swift
public mutating func add<C>(constraint: C) where T == C.InputType, C : AsyncConstraint
Parameters
constraint
-
Asynchronous evaluates the input on all
AsyncConstraint
s until the first fails.Declaration
Swift
public func evaluateAny(input: T, queue: DispatchQueue = .main, completionHandler: @escaping (_ result: ValidationResult) -> 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
.success
if the input is valid,.failure
containing theError
registered with the failingAsyncConstraint
otherwise. -
Asynchronous evaluates the input on all
AsyncConstraint
s in the collection.Declaration
Swift
public func evaluateAll(input: T, queue: DispatchQueue = .main, completionHandler: @escaping (_ result: ValidationResult) -> 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 eachAsyncConstraint
in collection.