Skip to content

ifThenElse

ifThenElse(condition, thenValue, elseValue) → any · Type

Inline if-then-else conditional expression. Returns thenValue if condition is true, otherwise elseValue.

  • condition (required): boolean condition

  • thenValue (required): value if true

  • elseValue (required): value if false

bash
echo '{"age": 20}' | utlx -e 'ifThenElse($input.age >= 18, "adult", "minor")'
# "adult"
utlx
{
  status: ifThenElse($input.active, "ACTIVE", "INACTIVE"),
  label: ifThenElse($input.count > 0, concat(toString($input.count), " items"), "empty")
}

Released under AGPL-3.0.