String Columns
How to add a string column to your importer through code.
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 String column is the most versatile column type. It accepts any strings, and has a number of different ways to validate or transform values.
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 “string”.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 String Validations.transformations
(Optional): An array of built-in data transformations. See Built-in String Transformations.
Example Code
Built-in String Validations
The addColumn
object accepts an array of validations. Each validation has three properties:
validation_type:
the name of the validationmessage:
the message showed to the end user if the validation failsoptions:
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:
cannot_contain
Specifies that the column cannot contain a specific pattern.
contain
Specifies that column must contain a specific pattern.
max_length
Specifies the maximum character length of the column.
min_length
Specifies the minimum character length of the column.
length_exactly
Specifies the exact length that the column must have.
unique_case_sensitive
Specifies that the value must be unique using case-sensitive comparison.
unique_case_insensitive
Specifies that the value must be unique using case-insensitive comparison.
regex
Specifies that the value must match a regex.
Built-in String 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:
sentence_case
This transformation converts all the strings in the column to sentence case. For example, “hello world” becomes “Hello world”.
capitalize
This transformation capitalizes the first letter of each string in the column while making the remaining letters lowercase. For example, “apple” becomes “Apple”.
uppercase
This transformation converts all the strings in the column to uppercase. For example, “hello” becomes “HELLO”.
lowercase
This transformation converts all the strings in the column to lowercase. For example, “WORLD” becomes “world”.
trim_whitespace
This transformation removes any leading or trailing whitespace characters (spaces, tabs, etc.) from each string in the column. For example, ” hello ” becomes “hello”.