You can add a column to your importer directly through the UI of your Fuse account, or you can do so in code using the documentation below.

The URL column type validates that values are a valid URL. By default, this column type accepts formats like:

If you want to validate that all URLs in the column contain a protocol (e.g., “https://”), you can add a custom validation.

addColumn Function

The addColumn function accepts an object as an argument.

  • internal_key (String) - required: The internal key used to access a column’s value.
  • label (String) - required: The user-facing column label that is shown in the interface.
  • column_type (String) - required: Should be “url”.
  • required (String) - required: Whether or not the column is required.
  • position (Optional): The position or order of the column.
  • unique (Optional): Whether values should be unique.
  • validations (Optional): An array of built-in data validations. See Built-in URL Validations.
  • transformations (Optional): An array of built-in data transformations. See Built-in URL Transformations

Example Code

  const importer = new FuseImporter(organizationApiKey, importerId);

  const validations = [
    {
      validation_type: "max_length",
      message: "The URL should not be longer than 18 characters",
      options: {
        max_length: 18,
      },
    },
  ];

  const transformations = [
    {
      validation_type: "prefix",
      options: {
        prefix: "https://",
      },
    },
  ];

  importer.addColumn({
    internal_key: "url",
    label: "URL",
    column_type: "url",
    required: true,
    position: 1,
    unique: true,
    validations: validations,
    transformations: transformations,
  });

  importer.show();

Built-in URL Validations

The options property of addColumn accepts an array of validations. Each validation has three properties:

  • validation_type: the name of the validation
  • message: the message showed to the end user if the validation fails
  • options: options for the specific validation type

The validations property accepts an array of objects that contains these possible values: validation_type, message, and options. As the example below:

validations: [
  {
    validation_type: "cannot_contain",
    message: "Cannot contain .net",
    options: {
      pattern: ".net",
    },
  },
];

cannot_contains

Specifies that the column cannot contain a specific pattern.

validations: [
  {
    validation_type: "cannot_contain",
    message: "Cannot contain .net",
    options: {
      pattern: ".net",
    },
  },
];

contain

Specifies that column must contain a specific pattern.

validations: [
  {
    validation_type: "contain",
    message: "Must contain https://",
    options: {
      pattern: "https://",
    },
  },
];

max_length

Specifies the maximum character length of the column.

validations: [
  {
    validation_type: "max_length",
    message: "Must be less than 10 characters",
    options: {
      max_length: 9,
    },
  },
];

min_length

Specifies the minimum character length of the column.

validations: [
  {
    validation_type: "min_length",
    message: "Must be at least 10 characters",
    options: {
      min_length: 10,
    },
  },
];

length_exactly

Specifies the exact length that the column must have.

validations: [
  {
    validation_type: "length_exactly",
    message: "Must be exactly 10 characters",
    options: {
      length: 10,
    },
  },
];

unique_case_sensitive

Specifies that the value must be unique using case-sensitive comparison.

validations: [
  {
    validation_type: "unique_case_sensitive",
    message: "Must be unique",
  },
];

unique_case_insensitive

Specifies that the value must be unique using case-insensitive comparison.

validations: [
  {
    validation_type: "unique_case_insensitive",
    message: "Must be unique",
  },
];

regex

Specifies that the value must match a regex.

validations: [
  {
    validation_type: "regex",
    message: "Must be a valid domain name",
    options: {
      pattern: /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9](?:\.[a-zA-Z]{2,})+$/,
    },
  },
];

Built-in URL Transformations

The options property of addColumn accepts an array of transformations. For the string transformations, you can specify one property:

  • transformation_type: the name of the transformation

The transformations property accepts an array of objects that contains these possible values: transformation_type. As the example below:

transformations: [
  {
    transformation_type: "prefix",
    options: {
      prefix: "https://",
    },
  },
];

prefix

The prefix transformation adds a specified prefix, such as “https://”, to each URL in the column. For example, “example.com” becomes ”https://example.com”. You should pass an options object to the transformation object with a prefix string value with your prefix.

transformations: [
  {
    transformation_type: "prefix",
    options: {
      prefix: "https://",
    },
  },
];