Left Pad
Overview
Use the left pad transform to pad an incoming string with a user-supplied character out to a specific number of characters. This transform is often useful for data normalization situations in which data such as employee IDs are not uniform in length but need to be for downstream systems.
- If the input to the left pad transform is null, the transform returns a null value.
Transform structure
In addition to the standard type and name attributes, the left pad transform requires the length attribute, which tells the transform how many characters to pad the incoming string to.
{
"attributes": {
"padding": "0",
"length": "5"
},
"type": "leftPad",
"name": "Left Pad Transform"
}
Top-level properties (required)
-
type
string(required)
Must be set toleftPad. -
name
string(required)
The name of the transform as it will appear in the UI's dropdown menus. -
requiresPeriodicRefresh
boolean(optional)
Whether the transform logic should be reevaluated every evening as part of the identity refresh process. Default isfalse.
Attributes
The left pad transform uses the following structure:
{
"type": "leftPad",
"name": "Transform Name",
"attributes": {
"length": "8",
"padding": "0"
}
}
attributes (required)
The attributes object contains the padding configuration.
Required
- length
string(required)
An integer value for the final output string's desired length.
Optional
-
padding
string(optional)
The character to use for padding the incoming data to reach the desired length. Default is a single space" ". -
input
object(optional)
Explicitly defines the input data passed into the transform. If not provided, the transform uses input from the source and attribute combination configured in the UI.
Examples
This transform takes the incoming attribute configured in the identity profile attribute UI and ensures it is padded out to 8 characters in length by adding "0"s to the left.
Input: "1234"
Output: "00001234"
Transform request body:
{
"attributes": {
"padding": "0",
"length": "8"
},
"type": "leftPad",
"name": "Left Pad Transform"
}
This transform takes the user's employeeID attribute from the HR source and ensures it is padded out to 7 characters in length by adding "x"s to the left.
Input: "1234"
Output: "xxx1234"
Transform request body:
{
"attributes": {
"padding": "x",
"length": "7",
"input": {
"attributes": {
"sourceName": "HR Source",
"attributeName": "employeeID"
},
"type": "accountAttribute"
}
},
"type": "leftPad",
"name": "Left Pad Transform"
}