Class ConditionalValidator<T, TResult>
- Namespace
- LfrlAnvil.Validation.Validators
- Assembly
- LfrlAnvil.Validation.dll
Represents a conditional generic object validator.
public sealed class ConditionalValidator<T, TResult> : IValidator<T, TResult>
Type Parameters
TObject type.
TResultResult type.
- Inheritance
-
ConditionalValidator<T, TResult>
- Implements
-
IValidator<T, TResult>
- Inherited Members
- Extension Methods
Constructors
ConditionalValidator(Func<T, bool>, IValidator<T, TResult>, IValidator<T, TResult>)
Creates a new ConditionalValidator<T, TResult> instance.
public ConditionalValidator(Func<T, bool> condition, IValidator<T, TResult> ifTrue, IValidator<T, TResult> ifFalse)
Parameters
conditionFunc<T, bool>Validator's condition. When it returns true, then IfTrue gets invoked, otherwise IfFalse gets invoked.
ifTrueIValidator<T, TResult>Underlying validator invoked when Condition returns true.
ifFalseIValidator<T, TResult>Underlying validator invoked when Condition returns false.
Properties
Condition
Validator's condition. When it returns true, then IfTrue gets invoked, otherwise IfFalse gets invoked.
public Func<T, bool> Condition { get; }
Property Value
IfFalse
Underlying validator invoked when Condition returns false.
public IValidator<T, TResult> IfFalse { get; }
Property Value
- IValidator<T, TResult>
IfTrue
Underlying validator invoked when Condition returns true.
public IValidator<T, TResult> IfTrue { get; }
Property Value
- IValidator<T, TResult>
Methods
Validate(T)
Validates the provided obj.
[Pure]
public Chain<TResult> Validate(T obj)
Parameters
objTObject to validate.
Returns
- Chain<TResult>
Result of
objvalidation.