Class Validators<TResult>
- Namespace
- LfrlAnvil.Validation
- Assembly
- LfrlAnvil.Validation.dll
Creates instances of IValidator<T, TResult> type.
public static class Validators<TResult>
Type Parameters
TResult
Validator's result type.
- Inheritance
-
Validators<TResult>
- Inherited Members
Methods
All<T>(params IValidator<T, TResult>[])
Creates a new AndCompositeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> All<T>(params IValidator<T, TResult>[] validators)
Parameters
validators
IValidator<T, TResult>[]Underlying validators.
Returns
- IValidator<T, TResult>
New AndCompositeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Any<T>(params IValidator<T, TResult>[])
Creates a new OrCompositeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, OrValidatorResult<TResult>> Any<T>(params IValidator<T, TResult>[] validators)
Parameters
validators
IValidator<T, TResult>[]Underlying validators.
Returns
- IValidator<T, OrValidatorResult<TResult>>
New OrCompositeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Conditional<T>(Func<T, bool>, IValidator<T, TResult>, IValidator<T, TResult>)
Creates a new ConditionalValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> Conditional<T>(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.
Returns
- IValidator<T, TResult>
New ConditionalValidator<T, TResult> instance.
Type Parameters
T
Object type.
ElementCountInRange<T>(int, int, TResult)
Creates a new IsElementCountInRangeValidator<T, TResult> instance.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> ElementCountInRange<T>(int minCount, int maxCount, TResult failureResult)
Parameters
minCount
intMinimum expected number of elements.
maxCount
intMaximum expected number of elements.
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New IsElementCountInRangeValidator<T, TResult> instance.
Type Parameters
T
Element type.
Exceptions
- ArgumentOutOfRangeException
When
minCount
is not in [0,maxCount
] range.
Empty(TResult)
Creates a new IsLengthExactValidator<TResult> instance with Length equal to 0.
[Pure]
public static IValidator<string, TResult> Empty(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsLengthExactValidator<TResult> instance.
Empty<T>(TResult)
Creates a new IsElementCountExactValidator<T, TResult> instance with Count equal to 0.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> Empty<T>(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New IsElementCountExactValidator<T, TResult> instance.
Type Parameters
T
Element type.
EqualTo<T>(T, IEqualityComparer<T>, TResult)
Creates a new IsEqualToValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> EqualTo<T>(T determinant, IEqualityComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IEqualityComparer<T>Value equality comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
EqualTo<T>(T, TResult)
Creates a new IsEqualToValidator<T, TResult> instance with Default equality comparer.
[Pure]
public static IValidator<T, TResult> EqualTo<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
ExactElementCount<T>(int, TResult)
Creates a new IsElementCountExactValidator<T, TResult> instance.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> ExactElementCount<T>(int count, TResult failureResult)
Parameters
count
intExpected exact number of elements.
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New IsElementCountExactValidator<T, TResult> instance.
Type Parameters
T
Element type.
Exceptions
- ArgumentOutOfRangeException
When
count
is less than 0.
ExactLength(int, TResult)
Creates a new IsLengthExactValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> ExactLength(int length, TResult failureResult)
Parameters
Returns
- IValidator<string, TResult>
New IsLengthExactValidator<TResult> instance.
Exceptions
- ArgumentOutOfRangeException
When
length
is less than 0.
Fail<T>(TResult)
Creates a new FailingValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> Fail<T>(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New FailingValidator<T, TResult> instance.
Type Parameters
T
Object type.
GreaterThanOrEqualTo<T>(T, IComparer<T>, TResult)
Creates a new IsGreaterThanOrEqualToValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> GreaterThanOrEqualTo<T>(T determinant, IComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsGreaterThanOrEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
GreaterThanOrEqualTo<T>(T, TResult)
Creates a new IsGreaterThanOrEqualToValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> GreaterThanOrEqualTo<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsGreaterThanOrEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
GreaterThan<T>(T, IComparer<T>, TResult)
Creates a new IsGreaterThanValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> GreaterThan<T>(T determinant, IComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsGreaterThanValidator<T, TResult> instance.
Type Parameters
T
Object type.
GreaterThan<T>(T, TResult)
Creates a new IsGreaterThanValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> GreaterThan<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsGreaterThanValidator<T, TResult> instance.
Type Parameters
T
Object type.
IfFalse<T>(Func<T, bool>, IValidator<T, TResult>)
Creates a new ConditionalValidator<T, TResult> instance with a passing IfTrue validator.
[Pure]
public static IValidator<T, TResult> IfFalse<T>(Func<T, bool> condition, IValidator<T, TResult> validator)
Parameters
condition
Func<T, bool>Validator's condition. When it returns true, then IfTrue gets invoked, otherwise IfFalse gets invoked.
validator
IValidator<T, TResult>Underlying validator invoked when Condition returns false.
Returns
- IValidator<T, TResult>
New ConditionalValidator<T, TResult> instance.
Type Parameters
T
Object type.
IfIsNotOfType<T, TDestination>(IValidator<T, TResult>)
Creates a new TypeCastValidator<T, TDestination, TResult> instance with a passing IfIsOfType validator.
[Pure]
public static IValidator<T, TResult> IfIsNotOfType<T, TDestination>(IValidator<T, TResult> validator)
Parameters
validator
IValidator<T, TResult>Underlying validator invoked when validated object is not of
TDestination
type.
Returns
- IValidator<T, TResult>
New TypeCastValidator<T, TDestination, TResult> instance.
Type Parameters
T
Object type.
TDestination
Object type required for IfIsOfType validator invocation.
IfIsOfType<T, TDestination>(IValidator<TDestination, TResult>)
Creates a new TypeCastValidator<T, TDestination, TResult> instance with a passing IfIsNotOfType validator.
[Pure]
public static IValidator<T, TResult> IfIsOfType<T, TDestination>(IValidator<TDestination, TResult> validator)
Parameters
validator
IValidator<TDestination, TResult>Underlying validator invoked when validated object is of
TDestination
type.
Returns
- IValidator<T, TResult>
New TypeCastValidator<T, TDestination, TResult> instance.
Type Parameters
T
Object type.
TDestination
Object type required for IfIsOfType validator invocation.
IfTrue<T>(Func<T, bool>, IValidator<T, TResult>)
Creates a new ConditionalValidator<T, TResult> instance with a passing IfFalse validator.
[Pure]
public static IValidator<T, TResult> IfTrue<T>(Func<T, bool> condition, IValidator<T, TResult> validator)
Parameters
condition
Func<T, bool>Validator's condition. When it returns true, then IfTrue gets invoked, otherwise IfFalse gets invoked.
validator
IValidator<T, TResult>Underlying validator invoked when Condition returns true.
Returns
- IValidator<T, TResult>
New ConditionalValidator<T, TResult> instance.
Type Parameters
T
Object type.
InExclusiveRange<T>(T, T, IComparer<T>, TResult)
Creates a new IsInExclusiveRangeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> InExclusiveRange<T>(T min, T max, IComparer<T> comparer, TResult failureResult)
Parameters
min
TMinimum exclusive value to compare with.
max
TMaximum exclusive value to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsInExclusiveRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
InExclusiveRange<T>(T, T, TResult)
Creates a new IsInExclusiveRangeValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> InExclusiveRange<T>(T min, T max, TResult failureResult)
Parameters
min
TMinimum exclusive value to compare with.
max
TMaximum exclusive value to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsInExclusiveRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
InRange<T>(T, T, IComparer<T>, TResult)
Creates a new IsInRangeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> InRange<T>(T min, T max, IComparer<T> comparer, TResult failureResult)
Parameters
min
TMinimum value to compare with.
max
TMaximum value to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsInRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
InRange<T>(T, T, TResult)
Creates a new IsInRangeValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> InRange<T>(T min, T max, TResult failureResult)
Parameters
min
TMinimum value to compare with.
max
TMaximum value to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsInRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
LengthInRange(int, int, TResult)
Creates a new IsLengthInRangeValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> LengthInRange(int minLength, int maxLength, TResult failureResult)
Parameters
minLength
intMinimum expected Length.
maxLength
intMaximum expected Length.
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsLengthInRangeValidator<TResult> instance.
Exceptions
- ArgumentOutOfRangeException
When
minLength
is not in [0,maxLength
] range.
LessThanOrEqualTo<T>(T, IComparer<T>, TResult)
Creates a new IsLessThanOrEqualToValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> LessThanOrEqualTo<T>(T determinant, IComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsLessThanOrEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
LessThanOrEqualTo<T>(T, TResult)
Creates a new IsLessThanOrEqualToValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> LessThanOrEqualTo<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsLessThanOrEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
LessThan<T>(T, IComparer<T>, TResult)
Creates a new IsLessThanValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> LessThan<T>(T determinant, IComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsLessThanValidator<T, TResult> instance.
Type Parameters
T
Object type.
LessThan<T>(T, TResult)
Creates a new IsLessThanValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> LessThan<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsLessThanValidator<T, TResult> instance.
Type Parameters
T
Object type.
Match(Regex, TResult)
Creates a new IsRegexMatchedValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> Match(Regex regex, TResult failureResult)
Parameters
regex
RegexRegex to match.
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsRegexMatchedValidator<TResult> instance.
MaxElementCount<T>(int, TResult)
Creates a new MaxElementCountValidator<T, TResult> instance.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> MaxElementCount<T>(int maxCount, TResult failureResult)
Parameters
maxCount
intExpected maximum number of elements.
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New MaxElementCountValidator<T, TResult> instance.
Type Parameters
T
Element type.
Exceptions
- ArgumentOutOfRangeException
When
maxCount
is less than 0.
MaxLength(int, TResult)
Creates a new MaxLengthValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> MaxLength(int maxLength, TResult failureResult)
Parameters
Returns
- IValidator<string, TResult>
New MaxLengthValidator<TResult> instance.
Exceptions
- ArgumentOutOfRangeException
When
maxLength
is less than 0.
MinElementCount<T>(int, TResult)
Creates a new MinElementCountValidator<T, TResult> instance.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> MinElementCount<T>(int minCount, TResult failureResult)
Parameters
minCount
intExpected minimum number of elements.
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New MinElementCountValidator<T, TResult> instance.
Type Parameters
T
Element type.
Exceptions
- ArgumentOutOfRangeException
When
minCount
is less than 0.
MinLength(int, TResult)
Creates a new MinLengthValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> MinLength(int minLength, TResult failureResult)
Parameters
Returns
- IValidator<string, TResult>
New MinLengthValidator<TResult> instance.
Exceptions
- ArgumentOutOfRangeException
When
minLength
is less than 0.
NotEmpty(TResult)
Creates a new MinLengthValidator<TResult> instance with MinLength equal to 1.
[Pure]
public static IValidator<string, TResult> NotEmpty(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New MinLengthValidator<TResult> instance.
NotEmpty<T>(TResult)
Creates a new MinElementCountValidator<T, TResult> instance with MinCount equal to 1.
[Pure]
public static IValidator<IReadOnlyCollection<T>, TResult> NotEmpty<T>(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<IReadOnlyCollection<T>, TResult>
New MinElementCountValidator<T, TResult> instance.
Type Parameters
T
Element type.
NotEqualTo<T>(T, IEqualityComparer<T>, TResult)
Creates a new IsNotEqualToValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> NotEqualTo<T>(T determinant, IEqualityComparer<T> comparer, TResult failureResult)
Parameters
determinant
TValue to compare with.
comparer
IEqualityComparer<T>Value equality comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
NotEqualTo<T>(T, TResult)
Creates a new IsNotEqualToValidator<T, TResult> instance with Default equality comparer.
[Pure]
public static IValidator<T, TResult> NotEqualTo<T>(T determinant, TResult failureResult)
Parameters
determinant
TValue to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotEqualToValidator<T, TResult> instance.
Type Parameters
T
Object type.
NotInExclusiveRange<T>(T, T, IComparer<T>, TResult)
Creates a new IsNotInExclusiveRangeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> NotInExclusiveRange<T>(T min, T max, IComparer<T> comparer, TResult failureResult)
Parameters
min
TMinimum exclusive value to compare with.
max
TMaximum exclusive value to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotInExclusiveRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
NotInExclusiveRange<T>(T, T, TResult)
Creates a new IsNotInExclusiveRangeValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> NotInExclusiveRange<T>(T min, T max, TResult failureResult)
Parameters
min
TMinimum exclusive value to compare with.
max
TMaximum exclusive value to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotInExclusiveRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
NotInRange<T>(T, T, IComparer<T>, TResult)
Creates a new IsNotInRangeValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> NotInRange<T>(T min, T max, IComparer<T> comparer, TResult failureResult)
Parameters
min
TMinimum value to compare with.
max
TMaximum value to compare with.
comparer
IComparer<T>Value comparer.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotInRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
NotInRange<T>(T, T, TResult)
Creates a new IsNotInRangeValidator<T, TResult> instance with Default comparer.
[Pure]
public static IValidator<T, TResult> NotInRange<T>(T min, T max, TResult failureResult)
Parameters
min
TMinimum value to compare with.
max
TMaximum value to compare with.
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotInRangeValidator<T, TResult> instance.
Type Parameters
T
Object type.
Exceptions
- ArgumentOutOfRangeException
When
min
is greater thanmax
.
NotMatch(Regex, TResult)
Creates a new IsRegexNotMatchedValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> NotMatch(Regex regex, TResult failureResult)
Parameters
regex
RegexRegex to not match.
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsRegexNotMatchedValidator<TResult> instance.
NotMultiline(TResult)
Creates a new IsNotMultilineValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> NotMultiline(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsNotMultilineValidator<TResult> instance.
NotNull<T>(TResult)
Creates a new IsNotNullValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> NotNull<T>(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNotNullValidator<T, TResult> instance.
Type Parameters
T
Object type.
NotWhiteSpace(TResult)
Creates a new IsNotWhiteSpaceValidator<TResult> instance.
[Pure]
public static IValidator<string, TResult> NotWhiteSpace(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<string, TResult>
New IsNotWhiteSpaceValidator<TResult> instance.
Null<T>(TResult)
Creates a new IsNullValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> Null<T>(TResult failureResult)
Parameters
failureResult
TResultFailure result.
Returns
- IValidator<T, TResult>
New IsNullValidator<T, TResult> instance.
Type Parameters
T
Object type.
Pass<T>()
Creates a new PassingValidator<T, TResult> instance.
[Pure]
public static IValidator<T, TResult> Pass<T>()
Returns
- IValidator<T, TResult>
New PassingValidator<T, TResult> instance.
Type Parameters
T
Object type.
Switch<T, TSwitchValue>(Func<T, TSwitchValue>, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>)
Creates a new SwitchValidator<T, TResult, TSwitchValue> instance with a passing DefaultValidator validator.
[Pure]
public static IValidator<T, TResult> Switch<T, TSwitchValue>(Func<T, TSwitchValue> switchValueSelector, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>> validators) where TSwitchValue : notnull
Parameters
switchValueSelector
Func<T, TSwitchValue>Object's switch value selector.
validators
IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>Dictionary of validators identified by object's switch values.
Returns
- IValidator<T, TResult>
New SwitchValidator<T, TResult, TSwitchValue> instance.
Type Parameters
T
Object type.
TSwitchValue
Object's switch value type used as a validator identifier.
Switch<T, TSwitchValue>(Func<T, TSwitchValue>, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>, IValidator<T, TResult>)
Creates a new SwitchValidator<T, TResult, TSwitchValue> instance.
[Pure]
public static IValidator<T, TResult> Switch<T, TSwitchValue>(Func<T, TSwitchValue> switchValueSelector, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>> validators, IValidator<T, TResult> defaultValidator) where TSwitchValue : notnull
Parameters
switchValueSelector
Func<T, TSwitchValue>Object's switch value selector.
validators
IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>Dictionary of validators identified by object's switch values.
defaultValidator
IValidator<T, TResult>Default validator that gets chosen when object's switch value does not exist in the Validators dictionary.
Returns
- IValidator<T, TResult>
New SwitchValidator<T, TResult, TSwitchValue> instance.
Type Parameters
T
Object type.
TSwitchValue
Object's switch value type used as a validator identifier.
TypeCast<T, TDestination>(IValidator<TDestination, TResult>, IValidator<T, TResult>)
Creates a new TypeCastValidator<T, TDestination, TResult> instance.
[Pure]
public static IValidator<T, TResult> TypeCast<T, TDestination>(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.
Returns
- IValidator<T, TResult>
New TypeCastValidator<T, TDestination, TResult> instance.
Type Parameters
T
Object type.
TDestination
Object type required for IfIsOfType validator invocation.