Common Use Cases for the Elvis Operator in Okta Expression Language
Last Updated:
Overview
Okta supports the Elvis operator (?:) for Okta Expression Language (OEL) configuration. Administrators can utilize this operator to provide a default fallback value when an expression evaluates to a null or empty string.
Applies To
- Okta Identity Engine (OIE)
- Okta Classic Engine
- Okta Expression Language (OEL)
- User Lifecycle Management
Solution
What Is the Elvis Operator in Okta Expression Language?
Okta explicitly defines the Elvis operator (?:) as a binary operator that provides a default fallback value if an expression evaluates to null or an empty string ("").
The Elvis Operator Functions as an Alternative to Traditional Conditional Expressions
Administrators can create OEL syntax with the Elvis operator as an alternative to traditional conditional expressions.
How Does Okta Evaluate the Elvis Operator?
Administrators can compare the Elvis operator syntax to a traditional conditional expression.
(user.customEmailString ?: user.email)
This expression functions identically to the following traditional conditional expression:
user.customEmailString != "" AND user.customEmailString != null ? user.customEmailString : user.email
Evaluate the Elvis operator syntax by observing how Okta checks for non-null values, returns the primary string if valid, or falls back to the secondary string.
- Okta checks if
user.customEmailStringcontains a non-null, non-empty string value. - If
user.customEmailStringexists and is not empty, Okta returnsuser.customEmailString. - If
user.customEmailStringis eithernullor an empty string, Okta evaluates and returnsuser.emailinstead.
