Pattern Operators
Pattern operators let you match values against custom patterns and regular expressions.
Matches Pattern
Section titled “Matches Pattern”Match a value against a regex pattern:
__code__ of **Product** matches pattern "^[A-Z]{3}-\d{4}$"Interactive Example
Policy Rule
Test Data (JSON)
Matches Regex
Section titled “Matches Regex”An alias for matches pattern:
__zip__ of **Address** matches regex "^\d{5}(-\d{4})?$"Interactive Example
Policy Rule
Test Data (JSON)
Has the Format
Section titled “Has the Format”Check if a value matches a named format or pattern:
__phone__ of **Contact** has the format "phone"
__email__ of **User** has format "email"This is an alternative syntax for the validation operators. It supports the same format names: email, url, uuid, phone, phone number, date, time, datetime, iso8601.
Interactive Example
Policy Rule
Test Data (JSON)
Pattern Tips
Section titled “Pattern Tips”- Patterns use standard regex syntax
- Escape backslashes in strings:
\\dfor\d - Common patterns:
- US phone:
"^\\+?1?[-.\\s]?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}$" - ZIP code:
"^\\d{5}(-\\d{4})?$" - Product code:
"^[A-Z]{2,4}-\\d{3,6}$" - Hex color:
"^#[0-9a-fA-F]{6}$"
- US phone:
Summary
Section titled “Summary”| Operator | Description |
|---|---|
matches pattern "..." | Match against regex |
matches regex "..." | Alias for matches pattern |
has the format "..." | Match against named format |
has format "..." | Alias for has the format |