Skip to main content
The credentialsFormValidator option allows developers to inject a custom asynchronous validation callback into the widget. This callback will be called when the tenant submits their credentials in the widget. If the custom validator returns an errorMessage, it will be displayed to the tenant.

Syntax

credentialsFormValidator?: (
  oldConfig: TConfig,
  newConfig: TConfig,
  availableEntity: Record<string, unknown>,
  flowId: string,
  tenantId: string
) => Promise<{ errorMessage?: string; success: boolean }>;

Parameters

  • oldConfig: The current configuration settings before the tenant’s update.
  • newConfig: The updated configuration settings after the tenant’s modification.
  • availableEntity: The availableSource, availableTarget, or availableConnector that they are attempting linking ot
  • flowId
  • tenantId

Example Usage

Below is a simple example demonstrating how to implement the credentialsFormValidator:
const myValidator = async (
  oldConfig,
  newConfig,
  availableEntity,
  flowId,
  tenantId
) => {
  if(newConfig.api_version >= 25) {
    return {
        success: false,
        errorMessage: "Invalid API version specified"
    }
  }
  return { success: true };
};

hotglue.open(
    "tenant-id",
    {
        credentialsFormValidator: myValidator
    }
)
This example checks if a specific field has changed and returns an error message if so, ensuring tenants are informed of exact validation issues in the widget.