Skip to main content
Version: Preview (0.3.0-preview.205)

Class ValueObjectBound

Namespace: AdCodicem.ValueObjects
Assembly: AdCodicem.ValueObjects.Abstractions.dll

A generic bridge to the bounds a value object declares through and , used by generated code and by the registry.

public static class ValueObjectBound

Inheritance​

object ← ValueObjectBound

Inherited Members​

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

Remarks​

A static abstract member is reached through a type parameter, which finds it however the value object implements it. Named on the type, BirthDate.Minimum would miss an explicit implementation and fail to compile in a file the consumer cannot edit.

The bound is read from the value object each time it is asked for, and nothing keeps it. A bound is a constant, which the JIT folds into the check that reads it, so a copy would save nothing; and a copy taken while the value object's own static fields are still being initialized, by a well-known instance created before the bound is assigned, would keep the default of the type for the life of the process.

Methods​

Maximum<TSelf, TValue>()​

Gets the inclusive upper bound a value object declares.

public static TValue Maximum<TSelf, TValue>() where TSelf : IValueObjectMaximum<TValue>

Returns​

TValue

The bound.

Type Parameters​

TSelf

The value object.

TValue

Its underlying type.

Minimum<TSelf, TValue>()​

Gets the inclusive lower bound a value object declares.

public static TValue Minimum<TSelf, TValue>() where TSelf : IValueObjectMinimum<TValue>

Returns​

TValue

The bound.

Type Parameters​

TSelf

The value object.

TValue

Its underlying type.

Text<TValue>(TValue)​

Writes a bound as text, in the one invariant form a bound of its type is written in.

public static string Text<TValue>(TValue bound)

Parameters​

bound TValue

The bound.

Returns​

string

The text: digits for an integer or a decimal, the round-trip form of a real, the ISO 8601 form of a date or a time, the constant form of a duration, and the character itself for a .

Type Parameters​

TValue

The type of the bound.

Remarks​

It is the text the schema publishes, which the OpenAPI transformer and the type's own parser read back, and the text the message of a rejected value quotes.

A is written without its , neither a Z nor an offset: the check compares clock readings, whatever their kind, and a bound would otherwise publish the offset of whichever machine serves the document.