Class TypeCastValidator<T, TDestination, TResult>
- Namespace
- LfrlAnvil.Validation.Validators
- Assembly
- LfrlAnvil.Validation.dll
Represents a generic object validator that casts validated objects to TDestination
type
and performs conditional validation based on that type cast.
public sealed class TypeCastValidator<T, TDestination, TResult> : IValidator<T, TResult>
Type Parameters
T
Object type.
TDestination
Object type required for IfIsOfType validator invocation.
TResult
Result type.
- Inheritance
-
TypeCastValidator<T, TDestination, TResult>
- Implements
-
IValidator<T, TResult>
- Inherited Members
- Extension Methods
Constructors
TypeCastValidator(IValidator<TDestination, TResult>, IValidator<T, TResult>)
Creates a new TypeCastValidator<T, TDestination, TResult> instance.
public TypeCastValidator(IValidator<TDestination, TResult> ifIsOfType, IValidator<T, TResult> ifIsNotOfType)
Parameters
ifIsOfType
IValidator<TDestination, TResult>Underlying validator invoked when validated object is of
TDestination
type.ifIsNotOfType
IValidator<T, TResult>Underlying validator invoked when validated object is not of
TDestination
type.
Properties
IfIsNotOfType
Underlying validator invoked when validated object is not of TDestination
type.
public IValidator<T, TResult> IfIsNotOfType { get; }
Property Value
- IValidator<T, TResult>
IfIsOfType
Underlying validator invoked when validated object is of TDestination
type.
public IValidator<TDestination, TResult> IfIsOfType { get; }
Property Value
- IValidator<TDestination, TResult>
Methods
Validate(T)
Validates the provided obj
.
[Pure]
public Chain<TResult> Validate(T obj)
Parameters
obj
TObject to validate.
Returns
- Chain<TResult>
Result of
obj
validation.