Class InputValueObject<TValue>
Namespace: AdCodicem.ValueObjects.Blazor
Assembly: AdCodicem.ValueObjects.Blazor.dll
An input for a value object: reads the text a person types through the value object's rules, binds the normalized
instance, shows the message of the rule that refuses it, and keeps the rule's code on the form's
public class InputValueObject<TValue> : InputBase<TValue>, IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Type Parameters
TValue
The value object, or its nullable type.
Inheritance
object ← ComponentBase ← InputBase<TValue> ← InputValueObject<TValue>
Implements
IComponent, IHandleEvent, IHandleAfterRender, IDisposable
Inherited Members
InputBase<TValue>.FormatValueAsString(TValue?), InputBase<TValue>.TryParseValueFromString(string?, out TValue, out string?), InputBase<TValue>.SetParametersAsync(ParameterView), InputBase<TValue>.Dispose(bool), InputBase<TValue>.AdditionalAttributes, InputBase<TValue>.Value, InputBase<TValue>.ValueChanged, InputBase<TValue>.ValueExpression, InputBase<TValue>.DisplayName, InputBase<TValue>.EditContext, InputBase<TValue>.FieldIdentifier, InputBase<TValue>.CurrentValue, InputBase<TValue>.CurrentValueAsString, InputBase<TValue>.CssClass, InputBase<TValue>.NameAttributeValue, ComponentBase.BuildRenderTree(RenderTreeBuilder), ComponentBase.OnInitialized(), ComponentBase.OnInitializedAsync(), ComponentBase.OnParametersSet(), ComponentBase.OnParametersSetAsync(), ComponentBase.StateHasChanged(), ComponentBase.ShouldRender(), ComponentBase.OnAfterRender(bool), ComponentBase.OnAfterRenderAsync(bool), ComponentBase.InvokeAsync(Action), ComponentBase.InvokeAsync(Func<Task>), ComponentBase.DispatchExceptionAsync(Exception), ComponentBase.SetParametersAsync(ParameterView), ComponentBase.RendererInfo, ComponentBase.Assets, ComponentBase.AssignedRenderMode, object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
It renders a text <input>, as
Empty text binds null to a nullable value object, which [ValueObject<string>(AllowEmpty = true)], binds the instance it creates, and a type
that refuses it is answered with [Required] gives, "The {0} field is required.", {0} being
The text an instance shows is the text its type reads back: the value object's own text, written in the round-trip
form of its underlying type (2026-10-14 for a date), and the bare underlying value, in that same form, for a
type whose formatting hook writes something else. An instance equal to the default that its rules refuse, a field
nobody filled in, shows as empty text; one they accept, a zero they allow, shows as its value.
The text is read and written in th-TH or fa-IR, the culture's patterns and names stay, and a year typed is a Gregorian one.
A statically rendered form is mapped by the framework, through
The value object is found in
Properties
Culture
Gets or sets the culture the text is read and written in; when not set, the current culture where the component is interactive or prerenders for interactivity, the invariant one under static rendering.
[Parameter]
public CultureInfo? Culture { get; set; }
Property Value
Element
Gets or sets the associated
[DisallowNull]
public ElementReference? Element { get; protected set; }
Property Value
SchemaAttributes
Gets or sets a value indicating whether the input carries the maxlength, minlength and
pattern attributes the value object's rules give; off by default, since a browser checks the text as it is
typed, before the value object's normalizer runs.
[Parameter]
public bool SchemaAttributes { get; set; }
Property Value
Remarks
The lengths are counted in UTF-16 code units, by the browser as by .NET. The pattern is written only when a browser,
which compiles it with the v flag and matches it against the whole text, accepts every text the .NET pattern
accepts: a pattern each of whose alternatives is anchored at both ends, with no ., negated class or escape,
word boundary, class subtraction, surrogate, named block or category C or Cs, and nothing the shared
reader of .NET patterns refuses, such as a lookaround; \d, \w, \s and \p{…} are
written as the characters .NET matches them with. The attributes are written the first time an input of the type
asks for them. An attribute the input is given explicitly wins over the one the rules give.
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied
protected override void BuildRenderTree(RenderTreeBuilder builder)
Parameters
builder RenderTreeBuilder
A
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposing bool
FormatValueAsString(TValue?)
Formats the value as a string. Derived classes can override this to determine the formatting used for
protected override string? FormatValueAsString(TValue? value)
Parameters
value TValue?
The value to format.
Returns
A string representation of the value.
Remarks
TryParseValueFromString(string?, out TValue, out string?)
Parses a string to create an instance of TValue. Derived classes can override this to change how
protected override bool TryParseValueFromString(string? value, out TValue result, out string? validationErrorMessage)
Parameters
value string?
The string value to be parsed.
result TValue
An instance of TValue.
validationErrorMessage string?
If the value could not be parsed, provides a validation error message.
Returns
True if the value could be parsed; otherwise false.