Class ValidatorExtensions
- Namespace
- LfrlAnvil.Validation.Extensions
- Assembly
- LfrlAnvil.Validation.dll
Contains IValidator<T, TResult> extension methods.
public static class ValidatorExtensions
- Inheritance
-
ValidatorExtensions
- Inherited Members
Methods
ForCollectionElement<T, TResult>(IValidator<T, TResult>)
Creates a new ForEachValidator<T, TElementResult> instance.
[Pure]
public static IValidator<IReadOnlyCollection<T>, ElementValidatorResult<T, TResult>> ForCollectionElement<T, TResult>(this IValidator<T, TResult> validator)
Parameters
validator
IValidator<T, TResult>Underlying element validator.
Returns
- IValidator<IReadOnlyCollection<T>, ElementValidatorResult<T, TResult>>
New ForEachValidator<T, TElementResult> instance.
Type Parameters
T
Element type.
TResult
Element result type.
For<T, TTarget, TResult>(IValidator<T, TResult>, Func<TTarget, T>)
Creates a new SelectorValidator<T, TMember, TResult> instance.
[Pure]
public static IValidator<TTarget, TResult> For<T, TTarget, TResult>(this IValidator<T, TResult> validator, Func<TTarget, T> selector)
Parameters
validator
IValidator<T, TResult>Underlying validator.
selector
Func<TTarget, T>Validated value selector.
Returns
- IValidator<TTarget, TResult>
New SelectorValidator<T, TMember, TResult> instance.
Type Parameters
T
Validated value type.
TTarget
Object type.
TResult
Result type.
Format<T, TResource>(IValidator<T, ValidationMessage<TResource>>, IValidationMessageFormatter<TResource>, Func<IFormatProvider?>?)
Creates a new FormattedValidator<T, TResource> instance.
[Pure]
public static IValidator<T, FormattedValidatorResult<TResource>> Format<T, TResource>(this IValidator<T, ValidationMessage<TResource>> validator, IValidationMessageFormatter<TResource> formatter, Func<IFormatProvider?>? formatProvider = null)
Parameters
validator
IValidator<T, ValidationMessage<TResource>>Underlying validator.
formatter
IValidationMessageFormatter<TResource>Underlying validation message formatter.
formatProvider
Func<IFormatProvider>Optional format provider factory.
Returns
- IValidator<T, FormattedValidatorResult<TResource>>
New FormattedValidator<T, TResource> instance.
Type Parameters
T
Object type.
TResource
Message's resource type.
Map<T, TSourceResult, TResult>(IValidator<T, TSourceResult>, Func<Chain<TSourceResult>, Chain<TResult>>)
Creates a new MappedValidator<T, TSourceResult, TResult> instance.
[Pure]
public static IValidator<T, TResult> Map<T, TSourceResult, TResult>(this IValidator<T, TSourceResult> validator, Func<Chain<TSourceResult>, Chain<TResult>> resultMapper)
Parameters
validator
IValidator<T, TSourceResult>Underlying validator.
resultMapper
Func<Chain<TSourceResult>, Chain<TResult>>Underlying validator's result mapper.
Returns
- IValidator<T, TResult>
New MappedValidator<T, TSourceResult, TResult> instance.
Type Parameters
T
Object type.
TSourceResult
Underlying validator's result type.
TResult
Result type.