Class ValidatorExtensions
- Namespace
- Executables.Validation
- Assembly
- executables.dll
Extension methods for composing validators.
public static class ValidatorExtensions
- Inheritance
-
ValidatorExtensions
- Inherited Members
Methods
And<T>(Validator<T>, Validator<T>)
Combines two validators with logical AND semantics.
[Pure]
public static Validator<T> And<T>(this Validator<T> first, Validator<T> second)
Parameters
firstValidator<T>First validator in composition chain.
secondValidator<T>Second validator in composition chain.
Returns
- Validator<T>
Validator that succeeds only when both validators succeed.
Type Parameters
TValidated value type.
Exceptions
- ArgumentNullException
secondis null.
Or<T>(Validator<T>, Validator<T>)
Combines two validators with logical OR semantics.
[Pure]
public static Validator<T> Or<T>(this Validator<T> first, Validator<T> second)
Parameters
firstValidator<T>First validator in composition chain.
secondValidator<T>Second validator in composition chain.
Returns
- Validator<T>
Validator that succeeds when at least one validator succeeds.
Type Parameters
TValidated value type.
Exceptions
- ArgumentNullException
secondis null.
OverrideMessage<T>(Validator<T>, string)
Replaces the validation error message produced by a validator.
[Pure]
public static Validator<T> OverrideMessage<T>(this Validator<T> validator, string message)
Parameters
validatorValidator<T>Validator whose error message should be replaced.
messagestringReplacement error message.
Returns
- Validator<T>
Validator that preserves validation logic and overrides the error message.
Type Parameters
TValidated value type.
Exceptions
- ArgumentException
messageis empty.