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, ip, ip address, ipv4, ipv4 address, ipv6, ipv6 address, cidr, date, time, datetime, iso8601, json, base64, hex color, semver, toml, uri reference, data url, mac address.
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 |