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
FieldInputPointerJSON Pointer locating the offending field.
ReasonCodestringStable machine-readable code identifying the rule that was violated (e.g.
"required","length_out_of_range","invalid_format").ArgsImmutableDictionary<string, string>Optional structured arguments for the renderer (e.g.
{ "min": "3", "max": "50" }for a length-range violation). 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 (e.g. { "min": "3", "max": "50" }
for a length-range violation). 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
Field
JSON Pointer locating the offending field.
public InputPointer Field { get; init; }
Property Value
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
Methods
Equals(FieldViolation?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(FieldViolation? other)
Parameters
otherFieldViolationAn 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.