Each column type in Fuse has built-in validations. You refer to the documentation of a specific column type to see the available options.

When the built-in data validations are insufficient, you can create custom front-end data validations using the onValidateRecord hook on your importer.

onValidateRecord(record)

The onValidationRecord hook is called for each row (record) in the importer. It allows you to display front-end validations in the importer for the user to fix.

The record object passed to onValidateRecord contains all of the values for a single row in the importer. You can access values in the record object using the internal_key of each column in your importer.

The onValidateRecord hook returns an errors object with two properties:

  • errors block the user from submitting an import. These are items that must be fixed.
  • warnings provide a warning message to the user about potential issues. However, a user can submit an import with warnings present.

Example

importer.onValidateRecord = async (record) => {
  const errors = {};
  const warnings = {};

  // force emails to include gmail
  if (!record.email?.includes("gmail")) {
    errors["email"] = "Email must from gmail";
  }

  return {
    errors: errors,
    warnings: warnings,
  };
};