ValidationOptions.Localizer Property

Definition

Gets or sets the IValidationLocalizer used by the validation pipeline to resolve localized display names and error messages.

public:
 property Microsoft::Extensions::Validation::IValidationLocalizer ^ Localizer { Microsoft::Extensions::Validation::IValidationLocalizer ^ get(); void set(Microsoft::Extensions::Validation::IValidationLocalizer ^ value); };
public Microsoft.Extensions.Validation.IValidationLocalizer? Localizer { get; set; }
member this.Localizer : Microsoft.Extensions.Validation.IValidationLocalizer with get, set
Public Property Localizer As IValidationLocalizer

Property Value

Remarks

When null (the default), no localization is performed: literal display names from Name and DisplayName are returned as-is, and validation error messages fall back to the attribute's default message.

To enable the default IStringLocalizer-based implementation, add a reference to Microsoft.Extensions.Validation.Localization and call services.AddValidationLocalization() during DI configuration. Alternatively, assign a custom IValidationLocalizer implementation directly.

This property is intended to be configured during application startup. Mutating it after the validation pipeline has begun processing requests is not thread-safe.

Applies to