ValidationError
Defined in: core/src/errors/index.ts:393
Error thrown when argument validation fails before calling the canister. Contains detailed information about which fields failed validation.
Example
Section titled “Example”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" } // ] }}Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ValidationError(
methodName,issues):ValidationError
Defined in: core/src/errors/index.ts:399
Parameters
Section titled “Parameters”methodName
Section titled “methodName”string
issues
Section titled “issues”Returns
Section titled “Returns”ValidationError
Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”issues
Section titled “issues”
readonlyissues:ValidationIssue[]
Defined in: core/src/errors/index.ts:395
Array of validation issues
methodName
Section titled “methodName”
readonlymethodName:string
Defined in: core/src/errors/index.ts:397
The method name that failed validation
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON():
unknown
Defined in: core/src/errors/index.ts:413
JSON form, with any BigInt in the issues written as a string.
Returns
Section titled “Returns”unknown
getIssuesForPath()
Section titled “getIssuesForPath()”getIssuesForPath(
path):ValidationIssue[]
Defined in: core/src/errors/index.ts:423
Get the issues whose path contains the given segment: a field name, or an
array index. zod reports an index as a number, and 1 and "1" both
match it. Pass "" for issues about the whole argument (an empty path),
the key React’s mapValidationErrors files them under.
Parameters
Section titled “Parameters”string | number
Returns
Section titled “Returns”hasErrorForPath()
Section titled “hasErrorForPath()”hasErrorForPath(
path):boolean
Defined in: core/src/errors/index.ts:431
Check whether any issue’s path contains the given segment, matched the
same way as getIssuesForPath, "" included.
Parameters
Section titled “Parameters”string | number
Returns
Section titled “Returns”boolean