Skip to content

API ReferenceValidationFunction

getValidationErrorMessage()

function getValidationErrorMessage(error): string;

Returns text you can show the user for a validation issue.

It returns the issue’s own message when it has one, since that carries detail such as a shortfall amount. Otherwise it returns the standard message for the issue’s code, or Validation failed: <code> for a code it does not recognize.

It also accepts a bare { code } object, so you can pass a code from a failed step’s validationErrorResponse, such as RejectedByUser.

Parameters

ParameterTypeDescription
error| ValidationIssue | { code: BaseValidationErrorType | ValidationErrorCode; message?: string; }A ValidationIssue, or any object with a code and an optional message.

Returns

string

The message to display.