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

Interface IValueObjectMinimum<TValue>

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

Declares the inclusive lower bound of a value object, as a value of its underlying type.

public interface IValueObjectMinimum<TValue>

Type Parameters​

TValue

Underlying value type: a number, a , a date, a time or a duration.

Remarks​

The compiler checks the type of the bound, and the bound can be any expression of that type: public static DateOnly Minimum => new(1900, 1, 1);. The generated Validate refuses a smaller value with , and the OpenAPI schema publishes the bound, in the form the JSON converter writes it.

The bound is a constant. The check reads it each time it runs, which costs nothing for a constant, folded into the check by the JIT, while the schema reads it once, when the value object's type initializes, which the generated registration does as the declaring assembly loads. A bound that changed would therefore be checked against a value the schema does not publish, and a bound must neither throw nor depend on the state of the application. A bound relative to the clock, "not in the future" or "within 90 days", is a rule rather than a bound: implement it in , reading the time from a a test can fix.

Write it as an expression-bodied property, as above. An initialized property, { get; } = ..., is assigned with the type's other static fields, in the order they are declared: an instance created from a static field declared before it, public static readonly Percentage Full = Create(100);, would be checked against the default of the type.

Properties​

Minimum​

Gets the smallest value the value object accepts.

public static abstract TValue Minimum { get; }

Property Value​

TValue