Table of Contents

Class NonNegativeAttribute

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 strictly less than zero. Zero is accepted. Equivalent to [Range(0, MaxValue)].

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class NonNegativeAttribute : Attribute
Inheritance
NonNegativeAttribute
Inherited Members
Extension Methods

Remarks

Mutually exclusive with PositiveAttribute, 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.

See Also