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
FieldsEquatableArray<FieldViolation>Per-field validation failures.
RulesEquatableArray<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
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
Rules
Global or multi-field business-rule failures detected against the inbound shape.
public EquatableArray<RuleViolation> Rules { get; init; }
Property Value
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
codestringNon-blank machine-readable code identifying the violated rule.
fieldstringSimple property name or full JSON Pointer; null or empty targets the root.
argsImmutableDictionary<string, ValidationArgValue>Optional structured operands built with ValidationArgs.
detailstringOptional 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
codestringNon-blank machine-readable code identifying the violated rule.
fieldInputPointerJSON Pointer locating the offending field.
argsImmutableDictionary<string, ValidationArgValue>Operands of the rule (e.g.
maxLength,comparisonValue), built with ValidationArgs. Never put the rejected value itself here.detailstringOptional 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
codestringNon-blank machine-readable code identifying the rule.
fieldsIReadOnlyList<InputPointer>Related field pointers, copied in order. Null means no associated fields.
argsImmutableDictionary<string, ValidationArgValue>Operands of the rule, built with ValidationArgs. Never put a rejected value itself here.
detailstringOptional 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
fieldNamestringProperty name or full JSON Pointer; null or empty targets the root.
detailstringOptional 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
fieldInputPointerThe pointer locating the missing field.
detailstringOptional human-readable violation detail.
Returns
- Error.InvalidInput
The same error shape as
ForField(ValidationCodes.ValueNotNull, field, detail: detail).