Class ValueObjectSchema
Namespace: AdCodicem.ValueObjects.Metadata
Assembly: AdCodicem.ValueObjects.Abstractions.dll
The declarative constraints of a value object, captured once at compile time.
public sealed record ValueObjectSchema : IEquatable<ValueObjectSchema>
Inheritance
Implements
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks
The generator fills this from the ValueObjectAttribute so that the rules enforced by
Validate and the rules published in the OpenAPI schema or applied to an EF Core column can never
drift apart: they all read the same instance.
That instance is the value object's Validate enforces.
Properties
Comparison
Gets how the value object compares two values of its text, if the schema states it.
public StringComparison? Comparison { get; init; }
Property Value
Remarks
The generator states here the Comparison of the ValueObjectAttribute on every value object over
text,
A check written from the known values alone and compared exactly, the enum of the MongoDB collection
validator or the IN of an Entity Framework Core CHECK constraint, reads it: a closed set compared
A schema built by hand states the comparison its Validate looks the known values up with. Left
null, those checks try the spellings a comparison ignoring case, or a culture's ignoring a soft
hyphen, would take for a known value, and write one when the type stores none of them; a culture's comparison
takes other spellings still, so a schema over such a set states it.
Description
Gets the human-readable description of the value object, if any.
public string? Description { get; init; }
Property Value
Example
Gets an example value, boxed, if any.
public object? Example { get; init; }
Property Value
Remarks
The generator holds here the underlying value of the example the value object declares through
Format
Gets the OpenAPI format keyword for the value, if any.
public string? Format { get; init; }
Property Value
IsClosedValueSet
Gets a value indicating whether only
public bool IsClosedValueSet { get; init; }
Property Value
IsUnicode
Gets whether the text is stored as Unicode text, if the schema states it: false for a value
object declaring Unicode = false.
public bool? IsUnicode { get; init; }
Property Value
bool?
Remarks
The generator states false where the declaration does, and leaves it null
otherwise, an entity identifier's included. The Entity Framework Core conventions map such a value object to
non-Unicode text, and the Dapper handler declares its parameters DbType.AnsiString; true
and null leave both to the provider. It is no rule: nothing validates the text against it. A
schema built by hand states it as the option would.
KnownValueDetails
Gets the declared known values with the name and the description each was declared with, in declaration order.
public ImmutableArray<KnownValueInfo> KnownValueDetails { get; init; }
Property Value
ImmutableArray<KnownValueInfo>
Remarks
The generator lists here the values of Description its attribute gives, if any. The
OpenAPI integration publishes the names of a closed value set beside its enum, as
x-enum-varnames, x-enumNames and x-ms-enum, which client generators name the members of
their enumeration after.
A schema built by hand fills it as well, listing the values of AdCodicem.ValueObjects.Testing fails a schema that leaves it empty beside
known values, or out of step with them.
KnownValues
Gets the declared known underlying values, boxed, in declaration order.
public ImmutableArray<object> KnownValues { get; init; }
Property Value
Remarks
Surfaced as the enum keyword of the OpenAPI schema.
MaxLength
Gets the maximum accepted length, if any.
public int? MaxLength { get; init; }
Property Value
int?
Remarks
Used by the EF Core integration to size the mapped column.
Maximum
Gets the inclusive upper bound in invariant culture, if any.
public string? Maximum { get; init; }
Property Value
MinLength
Gets the minimum accepted length, if any.
public int? MinLength { get; init; }
Property Value
int?
Minimum
Gets the inclusive lower bound in invariant culture, if any.
public string? Minimum { get; init; }
Property Value
Pattern
Gets the regular expression the value must match, if any.
public string? Pattern { get; init; }
Property Value
Unconstrained
Gets the schema of a value object that declares no constraint.
public static ValueObjectSchema Unconstrained { get; }