Skip to content

String Operations

The Bridge provides a standard suite of tools for basic string manipulation under the std.str namespace.

Because all string tools accept a single .in parameter, they are perfectly designed to be used with the Pipe Operator (:)

Converts the input string to UPPER CASE.

  • Accepts: in (string)
  • Returns: string

Converts the input string to lower case.

  • Accepts: in (string)
  • Returns: string

Removes whitespace from both ends of the string.

  • Accepts: in (string)
  • Returns: string

Calculates the total number of characters in the string.

  • Accepts: in (string)
  • Returns: number

The most ergonomic way to use string tools is via inline pipes. The parser automatically routes the piped value into the tool’s .in parameter.

bridge Query.formatUser {
# Bring the tools into scope
with std.str.toUpperCase as upCase
with std.str.toLowerCase as lowCase
with input as i
with output as o
# i.lastName -> upCase -> o.lastName
o.lastName <- upCase:i.lastName
o.email <- lowCase:i.email
}

You can chain multiple string operations together. Remember that pipes evaluate from right to left!

bridge Query.normalizeEmail {
with std.str.trim as trim
with std.str.toLowerCase as lowCase
with input as i
with output as o
# Evaluates: i.rawEmail -> toLowerCase -> trim -> o.email
o.email <- trim:lowCase:i.rawEmail
}

If you prefer not to use pipes, or if you are dynamically building a string using interpolation before transforming it, you can explicitly wire data into the .in parameter.

bridge Query.getUsernameLength {
with std.str.length as getLen
with input as i
with output as o
# Explicitly wire the interpolated string into the tool
getLen.in <- "{i.firstName}_{i.lastName}"
o.characterCount <- getLen
}