IValidationLocalizer Interface

Definition

Provides localization services for the validation pipeline. Implementations resolve display names (used as {0} placeholder substitutions in error messages) and localized error message text for ValidationAttribute instances. Set an instance on Localizer to enable localization.

public interface class IValidationLocalizer
public interface IValidationLocalizer
type IValidationLocalizer = interface
Public Interface IValidationLocalizer

Remarks

The default implementation that integrates with Microsoft.Extensions.Localization.IStringLocalizer is provided by the Microsoft.Extensions.Validation.Localization package and is wired up by calling AddValidationLocalization(). Custom implementations can be supplied directly via Localizer.

Implementations may be invoked outside the validation pipeline (for example, during server-side rendering of client-side validation rules), so they must not depend on per-validation state and must be safe to call concurrently.

Methods

Name Description
ResolveDisplayName(DisplayNameLocalizationContext)

Resolves a localized display name for the member described by context.

ResolveErrorMessage(ErrorMessageLocalizationContext)

Resolves a fully-formatted localized error message for the validation attribute described by context.

Applies to