Class DiscoverableValidators

Namespace
Cratis.Arc.Validation
Assembly
Cratis.Arc.Core.dll

Represents an implementation of IDiscoverableValidators that can discover validators from assemblies.

public class DiscoverableValidators : IDiscoverableValidators
Inheritance
DiscoverableValidators
Implements
Inherited Members
Extension Methods

Constructors

DiscoverableValidators(ITypes)

Initializes a new instance of the DiscoverableValidators class.

public DiscoverableValidators(ITypes types)

Parameters

types ITypes

ITypes for type discovery.

Methods

TryGet(Type, out IValidator)

Try to get a validator for the given model type.

public bool TryGet(Type modelType, out IValidator validator)

Parameters

modelType Type

Type of model to get a validator for.

validator IValidator

The FluentValidation.IValidator if found.

Returns

bool

True if a validator was found, false otherwise.

TryGet(Type, IServiceProvider, out IValidator)

Try to get a validator for the given model type, resolving it from the supplied IServiceProvider.

public bool TryGet(Type modelType, IServiceProvider serviceProvider, out IValidator validator)

Parameters

modelType Type

Type of model to get a validator for.

serviceProvider IServiceProvider

The IServiceProvider to resolve the validator and its dependencies from.

validator IValidator

The FluentValidation.IValidator if found.

Returns

bool

True if a validator was found, false otherwise.

Remarks

Resolving from a command-scoped provider lets a validator take scoped dependencies — such as read models resolved for the command's event source id — exactly like a command's Handle() method.