PingOne

Operators

Operators are constructs used to manipulate individual data items and data sets. These include arithmetic, comparison, and logical operations.

Relational operators

The following relational operators are supported by using standard operator notation:

  • Equal

  • Not equal

  • Less than

  • Less than or equal to

  • Greater than

  • Greater than or equal to

Each symbolic operator can also be specified as a purely alphabetic equivalent that is case insensitive.

All operator notations except for ! require a leading and trailing space.

Alphabetic relational operator Examples
  • lt

  • <

5 lt 12

5 < 12

user.activeDays < 30

Because the operator is missing a leading and trailing space, user.activeDays<30 is incorrect.

  • le

6 le 6

6 ⇐ 6

user.activeDays ⇐ 30

  • gt

  • >

12 gt 5

12 > 5

user.activeDays > 30

  • ge

  • >=

12 ge 5

12 >= 5

user.activeDays >= 30

  • eq

  • ==

5 eq 5

5 == 5

user.activeDays == 30

  • ne

  • !=

6 ne 5

6 != 5

user.activeDays != 30

  • not

  • !

not (4 > 3)

!(user.activeDays < 30)

matches

Checks if a value matches the regular expression pattern.

'name' matches '[a-z]+'

Logical operators

All logical operator notations except for ! require a leading and trailing space.

Logical operator Example

and

5 > 3 and 4 ⇐ 4

or

5 > 3 or 4 < 3

  • not

  • !

5 < 13 and not (4 < 3)

5 > 6 and ! 4 < 14

Mathematical operators

All the following operators used for binary operation require a leading and trailing space.

Mathematical operator Description

+

Add numbers or concatenate if one of the operands is a string.

5 + 6

'Test' + 3

Because one of the operands is a string, it will return a string concatenation.

user.loginAttempts + user.logoutAttempts

Because the operator is missing a leading and trailing space, 5+6 is incorrect.

-

Subtraction

7 - 5

user.totalLicenses - user.activeLicenses

Because the operator is missing a leading and trailing space, 7-5 is incorrect.

*

Multiplication

3 * 5

user.avgLoginsPerMonth * 12

/

Division

12 / 3

user.totalLogins / 12

%

Modulus: Get remainder after division

7 % 4

^

Exponential Power

2 ^ 3, which is equivalent to (2 * 2 * 2)

Ternary operator

You can use the ternary operator to perform single line if-then-else logic expressions.

user.enabled ? 'Active' : 'Inactive'

Elvis operator

The Elvis operator is a short form for the Ternary operator for null checks. This operator requires a leading and trailing space.

You can rewrite user.id != null ? user.id : 'N/A' as user.id ?: 'N/A'.