Table of Contents

Class SwitchValidator<T, TResult, TSwitchValue>

Namespace
LfrlAnvil.Validation.Validators
Assembly
LfrlAnvil.Validation.dll

Represents a generic switch of object validators.

public sealed class SwitchValidator<T, TResult, TSwitchValue> : IValidator<T, TResult> where TSwitchValue : notnull

Type Parameters

T

Object type.

TResult

Result type.

TSwitchValue

Object's switch value type used as a validator identifier.

Inheritance
SwitchValidator<T, TResult, TSwitchValue>
Implements
IValidator<T, TResult>
Inherited Members
Extension Methods

Constructors

SwitchValidator(Func<T, TSwitchValue>, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>, IValidator<T, TResult>)

public SwitchValidator(Func<T, TSwitchValue> switchValueSelector, IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>> validators, IValidator<T, TResult> defaultValidator)

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.

Properties

DefaultValidator

Default validator that gets chosen when object's switch value does not exist in the Validators dictionary.

public IValidator<T, TResult> DefaultValidator { get; }

Property Value

IValidator<T, TResult>

SwitchValueSelector

Object's switch value selector.

public Func<T, TSwitchValue> SwitchValueSelector { get; }

Property Value

Func<T, TSwitchValue>

Validators

Dictionary of validators identified by object's switch values.

public IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>> Validators { get; }

Property Value

IReadOnlyDictionary<TSwitchValue, IValidator<T, TResult>>

Methods

Validate(T)

Validates the provided obj.

[Pure]
public Chain<TResult> Validate(T obj)

Parameters

obj T

Object to validate.

Returns

Chain<TResult>

Result of obj validation.