ConditionedConstraint
public struct ConditionedConstraint<T, E> : Constraint where E : Error
A data type that links a Predicate
to an Error
that describes why the predicate evaluation has failed.
-
Declaration
Swift
public typealias InputType = T
-
Declaration
Swift
public typealias ErrorType = E
-
The number of conditions that must be evaluated i
Declaration
Swift
public var conditionsCount: Int { get }
-
Create a new
ConditionedConstraint
instanceDeclaration
Swift
public init<C>(_ constraint: C, conditions: [C]) where T == C.InputType, E == C.ErrorType, C : Constraint
Parameters
constraint
A
Constraint
to describes the evaluation rule.conditions
An array of
Constraints
that must fullfil before evaluating the constraint. -
Create a new
ConditionedConstraint
instanceDeclaration
Swift
public init<C>(_ constraint: C, conditions: C...) where T == C.InputType, E == C.ErrorType, C : Constraint
Parameters
constraint
A
Constraint
to describes the evaluation rule.conditions
An array of
Constraints
that must fullfil before evaluating the constraint. -
Evaluates the input on the
Predicate
.Declaration
Swift
public func evaluate(with input: T) -> Result<Void, Summary<E>>
Parameters
input
The input to be validated.
Return Value
.success
if the input is valid,.failure
containing theSummary
of the failingConstraint
s otherwise.