Beispiel #1
0
 /// <summary>
 /// Specifies an asynchronous condition limiting when the validator should not run.
 /// The validator will only be executed if the result of the lambda returns false.
 /// </summary>
 /// <param name="rule">The current rule</param>
 /// <param name="predicate">A lambda expression that specifies a condition for when the validator should not run</param>
 /// <param name="applyConditionTo">Whether the condition should be applied to the current rule or all rules in the chain</param>
 /// <returns></returns>
 public static IRuleBuilderOptions <T, TProperty> UnlessAsync <T, TProperty>(this IRuleBuilderOptions <T, TProperty> rule, Func <T, CancellationToken, Task <bool> > predicate, ApplyConditionTo applyConditionTo = ApplyConditionTo.AllValidators)
 {
     predicate.Guard("A predicate must be specified when calling UnlessAsync", nameof(predicate));
     return(rule.UnlessAsync((x, ctx, ct) => predicate(x, ct), applyConditionTo));
 }