Zetect Expressions & Transforms Back to zetect.inSwitch portal ⇄

Logic Transforms

Choose a value: map the input through a table with lookup, pick the first matching rule with decision, or choose between two branches with if. All comparisons are exact and case-sensitive.

Conditions

decision rules and if use the same when clause: a JSON object of attribute names and the values they must have.

"when": { "department": "IT", "location": "India" }
  • Every entry must match for the condition to be true.
  • Each key names an attribute. Expected values can contain ${name} tokens.
  • A missing attribute never matches, and an empty when never matches.
  • Conditions test attributes only, never the input or a pipeline's current value. In a provisioning risk Value transform, the only attribute is value.

lookup

Looks the input up in a table and returns the matching value. If the input is missing or is not a key in the table, returns the default. The input must equal a key exactly.

OptionDescriptionDefault
inputThe value to look up.The previous step's result in a pipeline; otherwise none
mappingA JSON object of keys and the values to return. Returned values can contain tokens; they can't be nested transforms.None: the default is returned
defaultThe value to return when nothing matches. It can contain tokens.None: no value is returned
{
  "type": "lookup",
  "input": "${department}",
  "mapping": { "IT": "Information Technology", "HR": "Human Resources" },
  "default": "Unknown"
}
department = HR    → Human Resources
department = Legal → Unknown
department = hr    → Unknown   (keys are case-sensitive)

decision

Tries a list of rules in order and returns the result of the first rule whose when condition matches. If no rule matches, returns the default. decision ignores input and the previous step's result.

OptionDescriptionDefault
rulesA JSON list of rules. Each rule is an object with when and then.None: the default is returned
rules[].whenThe condition. See Conditions.None: the rule never matches
rules[].thenThe value to return when the rule matches. It can contain tokens; it can't be a nested transform.None: no value is returned
defaultThe value to return when no rule matches.None: no value is returned
{
  "type": "decision",
  "rules": [
    { "when": { "department": "IT", "location": "India" },
      "then": "OU=India,OU=IT,DC=example,DC=com" },
    { "when": { "department": "IT", "location": "USA" },
      "then": "OU=USA,OU=IT,DC=example,DC=com" }
  ],
  "default": "OU=Users,DC=example,DC=com"
}
department = IT, location = India → OU=India,OU=IT,DC=example,DC=com
department = IT, location = UK    → OU=Users,DC=example,DC=com

Put the most specific rules first, because the first match wins.

if

Tests a when condition and returns then if it matches or else if it doesn't. Unlike decision, each branch can be plain text or a nested transform, and a nested transform receives the previous step's result when if runs inside a pipeline.

OptionDescriptionDefault
whenThe condition. See Conditions.None: the condition is false
thenReturned when the condition matches. Text or a transform.None: no value is returned
elseReturned when it doesn't. Text or a transform.None: no value is returned
{
  "type": "if",
  "when": { "employeeType": "Contractor" },
  "then": "OU=Contractors,DC=example,DC=com",
  "else": "OU=Employees,DC=example,DC=com"
}
employeeType = Contractor → OU=Contractors,DC=example,DC=com
employeeType = Employee   → OU=Employees,DC=example,DC=com

Nested transforms in the branches
{
  "type": "if",
  "when": { "employeeType": "Contractor" },
  "then": { "type": "concat", "values": ["c-", "${username}"] },
  "else": { "type": "lowercase", "input": "${username}" }
}
employeeType = Contractor, username = rkumar → c-rkumar
employeeType = Employee,   username = PSharma → psharma