Skip to content

API ReferenceErrorsInterface

ValidationIssue

A validation issue is a plain data object describing a single validation failure. Unlike the legacy ValidationError class, it does not extend Error and is trivially serializable, testable via deep equality, and carries no stack trace overhead.

Properties

code

readonly code: ValidationErrorCode;

Which check failed, as a stable ValidationErrorCode constant such as AmountExceedsCollateralBacking or ExpirationTooFar. Switch on it for programmatic handling; pass the whole issue to getValidationErrorMessage for user-facing text.


context?

readonly optional context?: Record<string, unknown>;

Machine-readable detail behind the code, keyed per rule: e.g. { available, required } for CollateralInsufficient, { min } / { max } for the credited-token bounds. Infrastructure failures are not validation issues: async rule failures reject the validation call.


field

readonly field: string;

The field associated with this issue. May differ from the rule’s errorField — errorField is used for UI slot routing while field identifies the specific input that caused the issue. For array items, field may name a sub-field (e.g., 'amount') while errorField names the array field (e.g., 'redemptions').


message?

readonly optional message?: string;

Optional human-readable text a rule attached when it had context worth including (a shortfall amount, an RPC error string). getValidationErrorMessage prefers this over the canonical per-code message when present.