Class RuleViolation
- Namespace
- Trellis
- Assembly
- Trellis.Core.dll
Describes a global or multi-field business-rule failure attached to a
Error.UnprocessableContent. Use this for invariant violations that are
not bound to a single field (e.g. "order_must_have_items",
"passwords_must_match", "cancel_after_ship").
public sealed record RuleViolation : IEquatable<RuleViolation>
- Inheritance
-
RuleViolation
- Implements
- Inherited Members
- Extension Methods
Constructors
RuleViolation(string, EquatableArray<InputPointer>, ImmutableDictionary<string, string>?, string?)
Describes a global or multi-field business-rule failure attached to a
Error.UnprocessableContent. Use this for invariant violations that are
not bound to a single field (e.g. "order_must_have_items",
"passwords_must_match", "cancel_after_ship").
public RuleViolation(string ReasonCode, EquatableArray<InputPointer> Fields = default, ImmutableDictionary<string, string>? Args = null, string? Detail = null)
Parameters
ReasonCodestringStable machine-readable code identifying the rule.
FieldsEquatableArray<InputPointer>Optional pointers to fields involved in the rule (used to highlight related inputs in a UI when no single field carries the violation).
ArgsImmutableDictionary<string, string>Optional structured arguments for the renderer. Compared by value contents.
DetailstringOptional caller-supplied detail string. When non-null the boundary renderer prefers this over the default template for ReasonCode.
Properties
Args
Optional structured arguments for the renderer. Compared by value contents.
public ImmutableDictionary<string, string>? Args { get; init; }
Property Value
Detail
Optional caller-supplied detail string. When non-null the boundary renderer prefers this over the default template for ReasonCode.
public string? Detail { get; init; }
Property Value
Fields
Optional pointers to fields involved in the rule (used to highlight related inputs in a UI when no single field carries the violation).
public EquatableArray<InputPointer> Fields { get; init; }
Property Value
ReasonCode
Stable machine-readable code identifying the rule.
public string ReasonCode { get; init; }
Property Value
Methods
Equals(RuleViolation?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(RuleViolation? other)
Parameters
otherRuleViolationAn object to compare with this object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.