Table of Contents

Class Error.UnprocessableContent

Namespace
Trellis
Assembly
Trellis.Core.dll

HTTP 422 — the request was well-formed but the content failed semantic validation.

public sealed record Error.UnprocessableContent : Error, IEquatable<Error>, IEquatable<Error.UnprocessableContent>
Inheritance
Error.UnprocessableContent
Implements
Inherited Members
Extension Methods

Constructors

UnprocessableContent(EquatableArray<FieldViolation>, EquatableArray<RuleViolation>)

HTTP 422 — the request was well-formed but the content failed semantic validation.

public UnprocessableContent(EquatableArray<FieldViolation> Fields, EquatableArray<RuleViolation> Rules = default)

Parameters

Fields EquatableArray<FieldViolation>

Per-field validation failures.

Rules EquatableArray<RuleViolation>

Global or multi-field business-rule failures.

Properties

Fields

Per-field validation failures.

public EquatableArray<FieldViolation> Fields { get; init; }

Property Value

EquatableArray<FieldViolation>

Kind

Gets the stable, IANA-aligned identifier for this case (e.g. "not-found", "unprocessable-content"). Suitable for telemetry, problem-details type URI synthesis, and wire serialization.

public override string Kind { get; }

Property Value

string

Rules

Global or multi-field business-rule failures.

public EquatableArray<RuleViolation> Rules { get; init; }

Property Value

EquatableArray<RuleViolation>

Methods

ForField(string, string, string?)

Convenience factory that produces an Error.UnprocessableContent carrying a single FieldViolation built from a property name. The property name is converted to a JSON Pointer via ForProperty(string); pass an empty or null string to target the document root.

public static Error.UnprocessableContent ForField(string propertyName, string reasonCode, string? detail = null)

Parameters

propertyName string

Simple property name or full JSON Pointer.

reasonCode string

Stable machine-readable code identifying the rule that was violated.

detail string

Optional human-readable detail; when supplied the boundary renderer prefers it over the default template for reasonCode.

Returns

Error.UnprocessableContent

A 422 error wrapping the single field violation.

ForField(InputPointer, string, string?)

Convenience factory that produces an Error.UnprocessableContent carrying a single FieldViolation at the supplied InputPointer. Use this overload when the pointer was already computed (e.g. nested or array-element pointers, or Root for object-level violations).

public static Error.UnprocessableContent ForField(InputPointer field, string reasonCode, string? detail = null)

Parameters

field InputPointer

JSON Pointer locating the offending field.

reasonCode string

Stable machine-readable code identifying the rule that was violated.

detail string

Optional human-readable detail; when supplied the boundary renderer prefers it over the default template for reasonCode.

Returns

Error.UnprocessableContent

A 422 error wrapping the single field violation.

ForRule(string, string?)

Convenience factory that produces an Error.UnprocessableContent carrying a single RuleViolation — the global / multi-field counterpart to ForField(string, string, string?). Use for invariants that are not bound to a single field (e.g. "order_must_have_items", "passwords_must_match").

public static Error.UnprocessableContent ForRule(string reasonCode, string? detail = null)

Parameters

reasonCode string

Stable machine-readable code identifying the rule.

detail string

Optional human-readable detail; when supplied the boundary renderer prefers it over the default template for reasonCode.

Returns

Error.UnprocessableContent

A 422 error wrapping the single rule violation.