API ReferenceErrorsClass
~~ValidationError~~
Represents a user-input validation failure from the SDK.
Produced only by the tier-1 field validators (validateAddress,
validateTokenAmount,
validateTag, validateNonEmpty)
inside Result.err; it is never thrown by the SDK. code and field carry the same meaning as on
ValidationIssue.
Deprecated
Use ValidationIssue instead. ValidationIssue is a plain data
interface — no Error class overhead, no stack traces, trivially serializable. This class will be
removed once all validators are migrated to produce ValidationIssue objects.
Example
const result = validateAddress(raw.trim());if (result.ok) return { address: result.value }; // EIP-55 checksummed// Tier-1 validators return ValidationError[] inside Result.err; nothing// throws, so read the first error rather than wrapping in try/catch.const [first] = result.errors;if (first?.code === ValidationErrorCode.AddressInvalid) { return { error: getValidationErrorMessage(first) };}return { error: `${first?.field}: ${first?.code}` };Extends
Error
Constructors
Constructor
new ValidationError( code, field, context?): ValidationError;Parameters
| Parameter | Type | Description |
|---|---|---|
code | ValidationErrorCode | Which check failed; the same ValidationErrorCode vocabulary as ValidationIssue. |
field | string | Name of the input the failure belongs to ('address', 'tokenAmount', 'tag'), used to route the error to a form field. |
context? | Record<string, unknown> | Optional machine-readable detail, mirroring ValidationIssue.context. |
Returns
ValidationError
Overrides
Error.constructor;Properties
code
readonly code: ValidationErrorCode;Which check failed; the same ValidationErrorCode vocabulary as ValidationIssue.
context?
readonly optional context?: Record<string, unknown>;Optional machine-readable detail, mirroring ValidationIssue.context.
field
readonly field: string;Name of the input the failure belongs to ('address', 'tokenAmount', 'tag'), used to route the
error to a form field.