Skip to main content
Version: 0.3.x (0.3.0)

Class ValueObjectInputOptions

Namespace: AdCodicem.ValueObjects.Blazor
Assembly: AdCodicem.ValueObjects.Blazor.dll

The messages the inputs of value objects answer a refusal with: the English message of the rule, or one read from a resource of the application, under the key of the rule's code.

public sealed class ValueObjectInputOptions

Inheritance​

object ← ValueObjectInputOptions

Inherited Members​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks​

The options of AddValueObjectInputs(options => …). Without a resource, a refusal keeps the English message of the rule. With one, the message is looked up under the keys of : the key of the code, 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 input's DisplayName, or else the name of its field, as {0}, followed by the arguments reads from the type's rules, from {1}. A key with no entry keeps the English message.

The current UI culture chooses the resource, and the current culture formats the arguments: the culture a Blazor Server circuit or a Blazor WebAssembly application runs in. The localizer comes from the application's services, which AddValueObjectInputs registers with AddLocalization(), keeping a registration the application made first. A template quoting an argument its code does not supply is the application's error, and its is not caught.

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, under the key of the rule's code.

public ValueObjectInputOptions UseResource<TResource>()

Returns​

ValueObjectInputOptions

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 ValueObjectInputOptions UseResource(Type resourceType)

Parameters​

resourceType Type

The type the resources are named after.

Returns​

ValueObjectInputOptions

These options, so calls can be chained.

Exceptions​

ArgumentNullException

resourceType is null.