What built-in transforms are available in Field Mappings?¶
There are a handful of built-in transforms you can use in your field mappings.
make_hash SHA256 hashes the value for security/anonymization.
transforms:
- name: make_hash
to_string converts the value to it’s string version using str()
transforms:
- name: to_string
date_convert parses the value as a date and return a format that is
compatible with Veza. Raise a warning if it is not possible to do so and
returns a blank value.
transforms:
- name: date_convert
email_convert parses the value as an email, raising an error if not possible
transforms:
- name: email_convert
make_number convert the value to a number, if possible
transforms:
- name: make_number
join_fields join a set of fields together with the given separator
transforms:
- name: join_fields
options:
- ","
- ['first_name', 'last_name']
join_fields_add join a set of fields together with the given separator
in a new field
transforms:
- name: join_fields_add
options:
- ","
- ['first_name', 'last_name']
replace converts the field, removing the passed in string
transforms:
- name: replace
options:
string: " "
jinja_render adds a new field by parsing a jinja2 template string. The current
row is passed in as row in the template. e.g. "{{row.firstname}.{{row.lastname}@example.com"
transforms:
- name: jinja_render
options:
template: "{{row.ADComputer_ObjectName}}"
jinja_render_convert converts an existing field by parsing a jinja2 template string. The current
row is passed in as row in the template. e.g. "{{row.firstname}.{{row.lastname}@example.com"
transforms:
- name: jinja_render_convert
options:
template: "{{row.ADComputer_ObjectName}}"
The getenv function is available as a global inside all Jinja2 templates. Use it to
resolve environment variables with an optional fallback default:
transforms:
- name: jinja_render
options:
template: "{{ getenv('ISSUER_URL', 'https://default.example.com') }}/api/users/{{ row.id }}"
See How to use environment variables in templates for details.
validate_boolean converts the field to a boolean (True/False). Log a
warning if not possible and return False by default.
transforms:
- name: validate_boolean
filter_by_field filters the stream on the field if it matches one of
the options passed in
transforms:
- name: filter_by_field
options:
matches:
- kevin
- paul
- peter
null_to_blank converts None to blank. FYI, this transform is
applied to all values by default.
lowercase converts the value to lowercase.
transforms:
- name: lowercase
pull_from adds a new field whose value is copied from another field
in the same record.
transforms:
- name: pull_from
options: source_field_name
lookup maps the field value through a static lookup table. Returns
the original value if the key is not found.
transforms:
- name: lookup
lookup:
active: "Active"
inactive: "Inactive"
pull_from_lookup combines pull_from and lookup in one step —
copies a value from another field and maps it through a lookup table.
transforms:
- name: pull_from_lookup
pull_from: status_code
lookup:
"1": "Active"
"0": "Inactive"
debug simply prints the value to stdout for debugging purposes.
strip removes leading and trailing whitespace from a string field.
Non-string values are returned unchanged.
transforms:
- name: strip
Can be chained with lowercase to replace the common value.strip().lower()
hook pattern:
transforms:
- name: strip
- name: lowercase
default_if_empty returns a configurable fallback when the field value is
falsy (None, "", 0, False, etc.). Truthy values are returned
unchanged. The fallback defaults to "" when options.default is not set.
transforms:
- name: default_if_empty
options:
default: "Standard User"
truncate clips a string field to a maximum length. Non-string values are
returned unchanged. options.max_length defaults to 255.
transforms:
- name: truncate
options:
max_length: 24
domain_strip parses a DOMAIN\account identity string and returns one
part. options.part is "account" (default) or "domain". Values without
a backslash are returned unchanged.
# Returns "jsmith" from "CORP\\jsmith" (default)
transforms:
- name: domain_strip
# Returns "CORP" from "CORP\\jsmith"
transforms:
- name: domain_strip
options:
part: domain
regex_match applies a regex pattern to a field value (stringified) and
returns a capture group. Uses re.search so the pattern can match anywhere;
use ^/$ anchors to restrict to the full value. options.group selects a
named group string or numbered group integer (default 1). Returns "" and
logs a warning when the pattern does not match or the group does not exist.
# Numbered group (default = 1)
transforms:
- name: regex_match
options:
pattern: "^([^@]+)@"
# Named group
transforms:
- name: regex_match
options:
pattern: "(?P<account>[\\w_-]+)$"
group: account
See also¶
How to configure field mappings - How to use transforms in a field_mapping block
Exhaust config.yaml before writing a hook - When transforms cover your use case and when they don’t