Table of Contents

Class FieldViolation

Namespace
Trellis
Assembly
Trellis.Core.dll

Describes a validation failure attached to a specific field of an input document. Used inside Error.UnprocessableContent.

public sealed record FieldViolation : IEquatable<FieldViolation>
Inheritance
FieldViolation
Implements
Inherited Members
Extension Methods

Constructors

FieldViolation(InputPointer, string, ImmutableDictionary<string, string>?, string?)

Describes a validation failure attached to a specific field of an input document. Used inside Error.UnprocessableContent.

public FieldViolation(InputPointer Field, string ReasonCode, ImmutableDictionary<string, string>? Args = null, string? Detail = null)

Parameters

Field InputPointer

JSON Pointer locating the offending field.

ReasonCode string

Stable machine-readable code identifying the rule that was violated (e.g. "required", "length_out_of_range", "invalid_format").

Args ImmutableDictionary<string, string>

Optional structured arguments for the renderer (e.g. { "min": "3", "max": "50" } for a length-range violation). 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 (e.g. { "min": "3", "max": "50" } for a length-range violation). 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

Field

JSON Pointer locating the offending field.

public InputPointer Field { get; init; }

Property Value

InputPointer

ReasonCode

Stable machine-readable code identifying the rule that was violated (e.g. "required", "length_out_of_range", "invalid_format").

public string ReasonCode { get; init; }

Property Value

string

Methods

Equals(FieldViolation?)

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

public bool Equals(FieldViolation? other)

Parameters

other FieldViolation

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.