Class TlumachDisplayNameResolver
- Namespace
- Tlumach.FluentValidation
- Assembly
- Tlumach.FluentValidation.dll
Provides the display names of properties from a Tlumach translation, for ValidatorOptions.Global.DisplayNameResolver.
For the property Name of the class Customer, the resolver looks up two keys: the type-qualified key {DisplayNamesGroup}.Customer.Name and the
member key {DisplayNamesGroup}.Name. The type is the type of the object that FluentValidation validates (the root object). A name in the language of the message
is preferred to a name in another language, so the first of these is returned:
- The text of the type-qualified key, found for the culture or its basic culture.
- The text of the member key, found for the culture or its basic culture.
- The text of the type-qualified key from the default file, or a text supplied by an
OnTranslationValueNotFoundhandler. - The text of the member key from the default file, or a text supplied by an
OnTranslationValueNotFoundhandler.
When neither key has text, the resolver returns null, and FluentValidation uses its default name. A rule that calls WithName is not affected.
The name is read when the rule is validated, for the same culture as the messages of the language manager.
public sealed class TlumachDisplayNameResolver
- Inheritance
-
TlumachDisplayNameResolver
- Inherited Members
Constructors
TlumachDisplayNameResolver(TranslationManager, string?)
Initializes a new instance of the TlumachDisplayNameResolver class.
public TlumachDisplayNameResolver(TranslationManager translationManager, string? displayNamesGroup = "DisplayNames")
Parameters
translationManagerTranslationManagerThe translation manager that provides the names.
displayNamesGroupstringThe group, in which the names are stored. null or empty for root keys.
Exceptions
- ArgumentNullException
Thrown when
translationManageris null.
Properties
DisplayNamesGroup
Gets the group, in which the names are stored.
public string? DisplayNamesGroup { get; }
Property Value
TranslationManager
Gets the translation manager that provides the names.
public TranslationManager TranslationManager { get; }
Property Value
Methods
Resolve(Type, MemberInfo, LambdaExpression)
Returns the display name of the member. The signature matches ValidatorOptions.Global.DisplayNameResolver.
public string? Resolve(Type type, MemberInfo member, LambdaExpression expression)
Parameters
typeTypeThe type of the validated object.
memberMemberInfoThe member being validated. May be null for rules that do not target a member.
expressionLambdaExpressionThe expression of the rule. Not used.