Class ValueObjectMessageOptions
Namespace: AdCodicem.ValueObjects.AspNetCore
Assembly: AdCodicem.ValueObjects.AspNetCore.Http.dll
Where a refused value object finds a message in the application's language: a resource read through
IStringLocalizerFactory, under the key of the rule's code.
public sealed class ValueObjectMessageOptions
Inheritance
object ← ValueObjectMessageOptions
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The options of WithValueObjectProblemDetails(messages => …) on a minimal API, of
AddValueObjects(messages => …) on MVC, and of UseValueObjectProblemDetails(messages => …) on an
Azure Functions HTTP trigger. Without a
resource, a refusal keeps the English message of the rule. With one, the message is looked up under the keys of
ValueObject.value_object.too_short, after the same key followed by .minimum or .maximum for a
range of one bound. It is formatted with the member the refusal is listed under as {0}, followed by the arguments
{1}. A key with no entry keeps the English message.
The current UI culture chooses the resource, and the current culture formats the arguments: with
UseRequestLocalization(), both follow the request. An Azure Functions invocation runs on the host's call, not
on the request's, so the Functions middleware applies the request's cultures itself: those
UseRequestLocalization() chose, or else those the application's RequestLocalizationOptions choose from
the request. The localizer comes from the request's services, which builder.Services.AddLocalization()
registers; without it, a refusal throws an
The type lives in AdCodicem.ValueObjects.AspNetCore.Http, beside
Properties
ResourceType
Gets the type whose resources hold the messages, or null to keep the English messages.
public Type? ResourceType { get; }
Property Value
Type?
Methods
UseResource<TResource>()
Reads the messages from the resources of TResource.
public ValueObjectMessageOptions UseResource<TResource>()
Returns
These options, so calls can be chained.
Type Parameters
TResource
The type the resources are named after, as IStringLocalizer<T> names them: an empty class of the
application, beside a .resx file of the same name for each culture.
UseResource(Type)
Reads the messages from the resources of a type.
public ValueObjectMessageOptions UseResource(Type resourceType)
Parameters
resourceType Type
The type the resources are named after.
Returns
These options, so calls can be chained.
Exceptions
resourceType is null.