Skip to content

ValidationError

Defined in: errors/index.ts:207

Error thrown when argument validation fails before calling the canister. Contains detailed information about which fields failed validation.

try {
await reactor.callMethod({
functionName: "transfer",
args: [{ to: "", amount: -100 }],
})
} catch (error) {
if (isValidationError(error)) {
console.log(error.issues)
// [
// { path: ["to"], message: "Recipient is required" },
// { path: ["amount"], message: "Amount must be positive" }
// ]
}
}
  • Error

new ValidationError(methodName, issues): ValidationError

Defined in: errors/index.ts:213

string

ValidationIssue[]

ValidationError

Error.constructor

readonly issues: ValidationIssue[]

Defined in: errors/index.ts:209

Array of validation issues


readonly methodName: string

Defined in: errors/index.ts:211

The method name that failed validation

getIssuesForPath(path): ValidationIssue[]

Defined in: errors/index.ts:229

Get issues for a specific field path

string

ValidationIssue[]


hasErrorForPath(path): boolean

Defined in: errors/index.ts:236

Check if a specific field has errors

string

boolean