Table of Contents

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

ReasonCode string

Stable machine-readable code identifying the rule.

Fields EquatableArray<InputPointer>

Optional pointers to fields involved in the rule (used to highlight related inputs in a UI when no single field carries the violation).

Args ImmutableDictionary<string, string>

Optional structured arguments for the renderer. Compared by value contents.

Detail string

Optional 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

ImmutableDictionary<string, string>

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

string

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

EquatableArray<InputPointer>

ReasonCode

Stable machine-readable code identifying the rule.

public string ReasonCode { get; init; }

Property Value

string

Methods

Equals(RuleViolation?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(RuleViolation? other)

Parameters

other RuleViolation

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.