Table of Contents

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

first Validator<T>

First validator in composition chain.

second Validator<T>

Second validator in composition chain.

Returns

Validator<T>

Validator that succeeds only when both validators succeed.

Type Parameters

T

Validated value type.

Exceptions

ArgumentNullException

second is 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

first Validator<T>

First validator in composition chain.

second Validator<T>

Second validator in composition chain.

Returns

Validator<T>

Validator that succeeds when at least one validator succeeds.

Type Parameters

T

Validated value type.

Exceptions

ArgumentNullException

second is 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

validator Validator<T>

Validator whose error message should be replaced.

message string

Replacement error message.

Returns

Validator<T>

Validator that preserves validation logic and overrides the error message.

Type Parameters

T

Validated value type.

Exceptions

ArgumentException

message is empty.