Table of Contents

Class TlumachFluentValidationServiceCollectionExtensions

Namespace
Tlumach.FluentValidation
Assembly
Tlumach.FluentValidation.dll

Registers the Tlumach integration of FluentValidation.

public static class TlumachFluentValidationServiceCollectionExtensions
Inheritance
TlumachFluentValidationServiceCollectionExtensions
Inherited Members

Methods

AddTlumachFluentValidation(IServiceCollection, Action<TlumachFluentValidationOptions>)

Creates a TlumachLanguageManager, installs it as ValidatorOptions.Global.LanguageManager, and registers it as a singleton for TlumachLanguageManager and FluentValidation.Resources.ILanguageManager. With UseDisplayNameResolver, it does the same for a TlumachDisplayNameResolver and ValidatorOptions.Global.DisplayNameResolver.

FluentValidation reads its language manager only from the process-wide ValidatorOptions.Global, so this method changes a global setting at the moment it is called. It can be combined with AddTlumachLocalization and AddValidatorsFromAssemblyContaining in any order.

A repeated call applies configure to the options of the first call. Because the language manager and the resolver copy the options when they are created, they are then created anew from these options and replace those of the earlier call, both in the services (which keep one registration of each) and in ValidatorOptions.Global. If the options no longer set UseDisplayNameResolver, the display name resolver that was installed before the first call is restored.

public static IServiceCollection AddTlumachFluentValidation(this IServiceCollection services, Action<TlumachFluentValidationOptions> configure)

Parameters

services IServiceCollection

The services.

configure Action<TlumachFluentValidationOptions>

Sets the options. TranslationManager is required.

Returns

IServiceCollection

The value of services.

Exceptions

ArgumentNullException

Thrown when an argument is null.

ArgumentException

Thrown when the callback leaves TranslationManager unset.