Class PositiveAttribute
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Marks a partial RequiredInt<TSelf>, RequiredLong<TSelf>, or
RequiredDecimal<TSelf>-derived class so the source generator rejects any value
that is not strictly greater than zero. Equivalent to applying
[Range(1, MaxValue)] for integer types and a positive-fractional [Range] for
decimal types, but reads as domain intent at the declaration site.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class PositiveAttribute : Attribute
- Inheritance
-
PositiveAttribute
- Inherited Members
- Extension Methods
Remarks
Mutually exclusive with NonNegativeAttribute, NegativeAttribute, and NonPositiveAttribute on the same type — the source generator emits a diagnostic when two are combined.
Not supported on RequiredGuid<TSelf>, RequiredDateTime<TSelf>, RequiredDateTimeOffset<TSelf>, RequiredBool<TSelf>, RequiredString<TSelf>, or RequiredEnum<TSelf>.
Properties
Code
Gets or sets an application-defined reason code that replaces the framework default on every failure this attribute produces.
public string? Code { get; set; }
Property Value
- string
A non-empty code, or null to keep the framework default. Setting it to an empty or whitespace string is a generator error (
TRLS060).
Remarks
The framework vocabulary is frozen so that one client catalog entry works across every Trellis service. An application that owns both ends of its own contract — it wrote the declaration and it writes the catalog key — may name the failure in its own terms instead, and nothing it does here can invalidate another party's catalog. An override carries no warning and no penalty.