Text transformers
Transformers for text manipulation
trimWhitespace
Removes leading and trailing whitespace from text values. Only affects string values; other types are left unchanged.
Payload: None required
{
key: 'name',
label: 'Customer name',
type: 'text',
transformers: [
{
action: 'trimWhitespace'
}
]
}Example:
- Input:
" John Doe " - Output:
"John Doe"
toUpperCase
Converts text to uppercase. Only affects string values; other types are left unchanged.
Payload: None required
{
key: 'country_code',
label: 'Country code',
type: 'text',
transformers: [
{
action: 'toUpperCase'
}
]
}Example:
- Input:
"us" - Output:
"US"
toLowerCase
Converts text to lowercase. Only affects string values; other types are left unchanged.
Payload: None required
{
key: 'email',
label: 'Email',
type: 'text',
transformers: [
{
action: 'toLowerCase'
}
]
}Example:
- Input:
"JOHN@EXAMPLE.COM" - Output:
"john@example.com"
titleCaseText
Converts text to title case by capitalizing the first letter of words. Only affects string values; other types are left unchanged.
Payload:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
allWords | boolean | No | false | Whether to capitalize all words or just the first word |
{
key: 'full_name',
label: 'Full name',
type: 'text',
transformers: [
{
action: 'titleCaseText',
payload: {
allWords: true
}
}
]
}Examples:
-
Input:
"hello world"withallWords: true -
Output:
"Hello World" -
Input:
"hello world"withallWords: false -
Output:
"Hello world"
padString
Pads strings to a specified length with a character. Only affects string values. If the string is already longer than the target length, it's left unchanged.
Payload:
| Property | Type | Required | Description |
|---|---|---|---|
length | number | Yes | Target length for the padded string |
char | string | Yes | Character(s) to use for padding |
position | 'start' | 'end' | Yes | Where to add the padding |
{
key: 'product_code',
label: 'Product code',
type: 'text',
transformers: [
{
action: 'padString',
payload: {
length: 5,
char: '0',
position: 'start'
}
}
]
}Example:
- Input:
"42" - Output:
"00042"
truncateText
Truncates text to a maximum length. Only affects string values longer than maxLength. Adds a suffix when truncated.
Payload:
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
maxLength | number | Yes | - | Maximum length before truncation |
suffix | string | No | '…' | Text to append when truncated |
{
key: 'description',
label: 'Description',
type: 'text',
transformers: [
{
action: 'truncateText',
payload: {
maxLength: 10,
suffix: '...'
}
}
]
}Example:
- Input:
"Hello World!" - Output:
"Hello Worl..."
stripHtmlTags
Removes HTML tags from text values. Strips all HTML/XML tags using regex. Only affects string values.
Payload: None required
{
key: 'content',
label: 'Content',
type: 'text',
transformers: [
{
action: 'stripHtmlTags'
}
]
}Example:
- Input:
"<p>Hello <strong>World</strong></p>" - Output:
"Hello World"
regexReplace
Replaces text matching a regular expression pattern. Only affects string values. Uses JavaScript RegExp for pattern matching.
Payload:
| Property | Type | Required | Description |
|---|---|---|---|
pattern | string | Yes | Regular expression pattern to match |
flags | string | No | RegExp flags (e.g., 'g' for global, 'i' for case-insensitive) |
replaceWith | string | Yes | Replacement string |
{
key: 'phone',
label: 'Phone',
type: 'text',
transformers: [
{
action: 'regexReplace',
payload: {
pattern: '\\d+',
flags: 'g',
replaceWith: 'X'
}
}
]
}Example:
- Input:
"abc123def456" - Output:
"abcXdefX"