Table of Contents

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

T

Object type.

TResult

Result 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

condition Func<T, bool>

Validator's condition. When it returns true, then IfTrue gets invoked, otherwise IfFalse gets invoked.

ifTrue IValidator<T, TResult>

Underlying validator invoked when Condition returns true.

ifFalse IValidator<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

Func<T, bool>

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

obj T

Object to validate.

Returns

Chain<TResult>

Result of obj validation.