Table of Contents

Class Error.InvalidInput

Namespace
Trellis
Assembly
Trellis.Core.dll

Inbound request payload failed semantic validation: one or more fields or rules rejected the input.

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

Constructors

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

Inbound request payload failed semantic validation: one or more fields or rules rejected the input.

public InvalidInput(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 detected against the inbound shape.

Properties

Fields

Per-field validation failures.

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

Property Value

EquatableArray<FieldViolation>

Kind

Gets the stable domain slug for this case (e.g. "not-found", "invalid-input"). Suitable for telemetry, observability dimensions, and as the durable identifier that boundary layers translate into transport-specific type identifiers.

public override string Kind { get; }

Property Value

string

Rules

Global or multi-field business-rule failures detected against the inbound shape.

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

Property Value

EquatableArray<RuleViolation>

Methods

ForField(string, string?, ImmutableDictionary<string, ValidationArgValue>?, string?)

Convenience factory that produces an Error.InvalidInput 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.InvalidInput ForField(string code, string? field, ImmutableDictionary<string, ValidationArgValue>? args = null, string? detail = null)

Parameters

code string

Non-blank machine-readable code identifying the violated rule.

field string

Simple property name or full JSON Pointer; null or empty targets the root.

args ImmutableDictionary<string, ValidationArgValue>

Optional structured operands built with ValidationArgs.

detail string

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

Returns

Error.InvalidInput

An Error.InvalidInput wrapping the single field violation.

ForField(string, InputPointer, ImmutableDictionary<string, ValidationArgValue>?, string?)

Convenience factory that produces an Error.InvalidInput carrying a single FieldViolation at the supplied InputPointer.

public static Error.InvalidInput ForField(string code, InputPointer field, ImmutableDictionary<string, ValidationArgValue>? args = null, string? detail = null)

Parameters

code string

Non-blank machine-readable code identifying the violated rule.

field InputPointer

JSON Pointer locating the offending field.

args ImmutableDictionary<string, ValidationArgValue>

Operands of the rule (e.g. maxLength, comparisonValue), built with ValidationArgs. Never put the rejected value itself here.

detail string

Optional human-readable detail.

Returns

Error.InvalidInput

An Error.InvalidInput wrapping the single field violation.

ForRule(string, IReadOnlyList<InputPointer>?, ImmutableDictionary<string, ValidationArgValue>?, string?)

Convenience factory that produces an Error.InvalidInput carrying a single RuleViolation — the global / multi-field counterpart to ForField. Use for invariants that are not bound to a single field (e.g. "order.must-have-items", "password.mismatch").

public static Error.InvalidInput ForRule(string code, IReadOnlyList<InputPointer>? fields = null, ImmutableDictionary<string, ValidationArgValue>? args = null, string? detail = null)

Parameters

code string

Non-blank machine-readable code identifying the rule.

fields IReadOnlyList<InputPointer>

Related field pointers, copied in order. Null means no associated fields.

args ImmutableDictionary<string, ValidationArgValue>

Operands of the rule, built with ValidationArgs. Never put a rejected value itself here.

detail string

Optional human-readable detail.

Returns

Error.InvalidInput

An Error.InvalidInput wrapping the single rule violation.

Required(string?, string?)

Creates a single required-field violation with ValueNotNull.

public static Error.InvalidInput Required(string? fieldName, string? detail = null)

Parameters

fieldName string

Property name or full JSON Pointer; null or empty targets the root.

detail string

Optional human-readable violation detail.

Returns

Error.InvalidInput

The same error shape as ForField(ValidationCodes.ValueNotNull, fieldName, detail: detail).

Required(InputPointer, string?)

Creates a required-field violation preserving the supplied pointer and input location.

public static Error.InvalidInput Required(InputPointer field, string? detail = null)

Parameters

field InputPointer

The pointer locating the missing field.

detail string

Optional human-readable violation detail.

Returns

Error.InvalidInput

The same error shape as ForField(ValidationCodes.ValueNotNull, field, detail: detail).