Equals
Checks if the value at a key equals a specified value.
Overview
The equals condition evaluates whether a field's value exactly matches a specified value. It works with strings, numbers, booleans, arrays, and objects, making it one of the most versatile conditions for exact matching scenarios.
Use Cases
- Status Matching: Route based on exact status values
- Boolean Flags: Check feature flags or boolean fields
- Exact Value Filtering: Filter for specific numeric or string values
- Object/Array Comparison: Compare complex nested structures
Configuration
| Setting | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The field path to check. Supports dot notation for nested fields. Use * to check all keys. |
value | any | Yes | The value to compare against. Can be string, number, boolean, array, or object. |
case_insensitive | boolean | No | If true, performs case-insensitive string comparison. |
not | boolean | No | If true, inverts the condition (matches if values are NOT equal). |
Value Format
Internally, all values are stored as strings. This means 123 matches both the number 123 and the string "123" in your data. To match only a specific type, wrap the value in quotes:
| Input | Matches |
|---|---|
hello | "hello" |
123 | 123 (number) and "123" (string) |
"123" | "123" (string only, not the number 123) |
true | true (boolean) and "true" (string) |
"true" | "true" (string only, not the boolean true) |
["a","b"] | ["a","b"] or ["b","a"] (order-independent) |
{"k":"v"} | {"k":"v"} |
Use quotes when you need to distinguish between a string and its numeric or boolean equivalent.
Examples
String Comparison
Check for exact string match:
Code
Matches:
Code
Does not match:
Code
Case-Insensitive String Comparison
Match strings regardless of case:
Code
Matches:
Code
Numeric Comparison
Check for exact numeric value:
Code
Matches:
Code
Does not match:
Code
Boolean Comparison
Check boolean fields:
Code
Matches:
Code
Does not match:
Code
Array Comparison (Unordered)
Compare arrays - order does not matter:
Code
Matches:
Code
Does not match:
Code
Object Comparison (Unordered)
Compare objects - key order does not matter:
Code
Matches:
Code
Does not match:
Code
Nested Field Comparison
Check values in nested fields:
Code
Matches:
Code
Not Equal Check
Match records where the value is NOT equal:
Code
Matches:
Code
Does not match:
Code
Wildcard Key Check
Check if any field equals a value:
Code
Matches:
Code
Common Patterns
Status-Based Routing
Route by exact status:
Code
Feature Flag Check
Route based on feature flags:
Code
Environment Routing
Route production vs non-production:
Code
Null Check
Check for null values:
Code
Matches:
Code
Does not match:
Code
Note: A missing field is different from a null value. Use key_exists to check for missing fields.
Exclude Specific Values
Filter out specific statuses:
Code
Best Practices
-
Use exact types: Ensure the value type matches your data (
1vs"1",truevs"true"). -
Use
case_insensitivewhen appropriate: For user-generated content or when case may vary. -
Remember array comparison is unordered:
["a", "b"]equals["b", "a"]. -
Remember object comparison is unordered: Key order doesn't matter for equality.
-
Use
equals_anyfor multiple values: If checking against several possible values,equals_anyis more readable. -
Null vs missing: Use
equalswithnullto check for null values; usekey_existsto check for missing fields.
Type Handling
| Data Type | Behavior |
|---|---|
| Strings | Direct comparison (case-sensitive by default) |
| Numbers | Numeric comparison (1 equals 1.0) |
| Booleans | Direct comparison (true vs false) |
| Arrays | Unordered deep comparison (same elements in any order) |
| Objects | Unordered deep comparison (same keys/values, any key order) |
| Null | Matches only null values (not missing fields) |
Limitations
- Single value comparison (use
equals_anyfor multiple values) case_insensitiveonly applies to string comparisons- Missing fields return
false(not equal to anything, includingnull)
Troubleshooting
String not matching:
- Check for exact case (use
case_insensitive: trueif needed) - Look for trailing spaces or hidden characters
- Verify encoding (special characters)
Number not matching:
- Ensure value is a number, not a string (
1vs"1") - Check for floating point precision issues
Boolean not matching:
- Use actual boolean values (
true/false), not strings - Check if your data source serializes booleans as strings
Array not matching:
- Ensure all elements are present
- Remember comparison is unordered
- Check for duplicate handling (duplicates must match)
Null not matching:
- A missing field is not the same as
null - Use
key_existswithnot: trueto check for missing fields