Rich Filters
Rich Filters — Learn how to use semantic scalars for filtering
Semantic scalar types extend basic scalars (String, Int, Boolean) with domain-specific operators and automatic validation. This reference documents the available types, their operators, and validation rules.
Semantic scalars are strongly-typed field values that understand their domain:
email: String — just text, no validationemail: EmailAddress — validates format, enables domain filteringWhen you use a semantic scalar, FraiseQL automatically generates:
| Type | Category | Use Case | Key Operators |
|---|---|---|---|
| Contact | User emails | domainEq, domainIn, domainEndswith, localPartStartswith | |
| PhoneNumber | Contact | Phone numbers | countryCodeEq, countryCodeIn, isValid, typeEq |
| URL | Contact | Web URLs | protocolEq, hostEq, pathStartswith |
| DomainName | Contact | Domain names | tldEq, tldIn |
| Hostname | Contact | Server hostnames | — |
| IBAN | Financial | Bank accounts | countryEq, checkDigitEq |
| CUSIP | Financial | US securities | — |
| ISIN | Financial | Int’l securities | — |
| SEDOL | Financial | UK securities | — |
| LEI | Financial | Legal entities | — |
| MIC | Financial | Exchanges | countryEq |
| CurrencyCode | Financial | ISO currencies | — |
| Money | Financial | Amounts | — |
| ExchangeCode | Financial | Stock symbols | — |
| ExchangeRate | Financial | Currency rates | withinRange |
| StockSymbol | Financial | Ticker symbols | eq |
| PostalCode | Location | Zip codes | — |
| Latitude | Location | Latitude coord | — |
| Longitude | Location | Longitude coord | — |
| Coordinates | Location | Lat/lng pairs | distanceWithin |
| Timezone | Location | IANA timezones | — |
| LocaleCode | Location | BCP47 locales | — |
| LanguageCode | Location | ISO639 codes | — |
| CountryCode | Location | ISO3166 codes | eq |
| Slug | Identifier | URL slugs | — |
| SemanticVersion | Identifier | SemVer (v1.2.3) | eq |
| HashSHA256 | Identifier | SHA256 hashes | — |
| APIKey | Identifier | API credentials | — |
| LicensePlate | Identifier | Vehicle plates | — |
| VIN | Identifier | Vehicle numbers | wmiEq |
| TrackingNumber | Identifier | Shipment tracking | carrierEq |
| ContainerNumber | Identifier | Container IDs | ownerCodeEq |
| IPAddress | Network | IPv4/IPv6 | versionEq |
| IPv4 | Network | IPv4 only | — |
| IPv6 | Network | IPv6 only | — |
| MACAddress | Network | MAC addresses | — |
| CIDR | Network | IP ranges | containsAddress |
| Port | Network | Port numbers | — |
| AirportCode | Transportation | Airport codes | — |
| PortCode | Transportation | Port codes | — |
| FlightNumber | Transportation | Flight numbers | — |
| Markdown | Content | Markdown text | — |
| HTML | Content | HTML markup | — |
| MimeType | Content | Content types | formatEq |
| Color | Content | Hex colors | formatEq |
| Image | Content | Image files | formatEq |
| File | Content | Attachments | — |
| DateRange | Ranges | Date intervals | overlaps |
| Duration | Ranges | ISO8601 durations | withinRange |
| Percentage | Ranges | 0-100 values | — |
Email addresses with domain-specific operators.
GraphQL Type:
type User { email: EmailAddress!}
input EmailAddressFilter { eq: String neq: String contains: String domainEq: String domainIn: [String!] domainEndswith: String}Python Decorator:
import fraiseqlfrom fraiseql.scalars import Email
@fraiseql.typeclass User: email: EmailOperators:
eq — Exact email matchneq — Not equalcontains — Partial match (substring)domainEq — Extract and match domain (e.g., “example.com”)domainIn — Domain matches one of listdomainEndswith — Domain ends with (e.g., “*.company.com”)Validation:
Example Query:
query { users(where: { email: { domainEq: "company.com" } }) { id email name }}Database Support: ✅ PostgreSQL · ✅ MySQL · ✅ SQLite · ✅ SQL Server
International phone numbers with country code extraction.
Operators:
eq — Exact number matchcountryCodeEq — Country code match (e.g., “+1” for US)typeEq — Type match (mobile, fixed, voip, etc.)Validation:
Example Query:
query { contacts(where: { phone: { countryCodeEq: "+1" } }) { id phone }}Web URLs with protocol and domain matching.
Operators:
eq — Exact URL matchprotocolEq — Protocol match (http, https, ftp)domainEq — Domain extraction and matchpathContains — URL path substringValidation:
Example Query:
query { websites(where: { homepage: { protocolEq: "https" } }) { id homepage }}Domain names (DNS).
Operators:
eq — Exact matchsuffixEq — TLD match (e.g., “.com”)level — Domain level depth (example.co.uk = level 3)Validation:
Server/network hostnames.
Operators:
eq — Exact hostname matchsuffixEq — Suffix match (e.g., “.local”)Validation:
International Bank Account Numbers.
Operators:
eq — Exact IBAN matchcountryEq — Country code extractionchecksumValid — IBAN MOD-97 validationValidation:
Example Query:
query { accounts(where: { iban: { countryEq: "DE" } }) { id iban currency }}Committee on Uniform Securities Identification Procedures (US securities).
Operators:
eq — Exact CUSIPissuerEq — Issuer code extractiontypeEq — Security typeValidation:
International Securities Identification Number.
Operators:
eq — Exact ISINcountryEq — Country code extractiontypeEq — Security typeValidation:
Stock Exchange Daily Official List (UK/Irish securities).
Operators:
eq — Exact SEDOLissuerEq — Issuer sectorValidation:
Legal Entity Identifier.
Operators:
eq — Exact LEIcountryEq — Jurisdiction extractionValidation:
Market Identifier Code (ISO 10383).
Operators:
eq — Exact MICtypeEq — Market type (XETR, XETRA, etc.)Validation:
ISO 4217 currency codes.
Operators:
eq — Exact code match (e.g., “USD”)symbolEq — Currency symbol ($, €, etc.)decimalPlacesEq — Decimal places (usually 2)Validation:
Example Query:
query { transactions(where: { currency: { symbolEq: "$" } }) { id amount currency }}Monetary amounts with currency.
Operators:
eq — Exact amountcurrencyEq — Currency matchamountGte / amountLte — Range queriesValidation:
Stock exchange codes.
Operators:
eq — Exact exchange codetypeEq — Exchange typeValidation:
Foreign exchange rates.
Operators:
eq — Exact ratebaseCurrencyEq — Base currency codequoteCurrencyEq — Quote currency codeValidation:
Stock ticker symbols.
Operators:
eq — Exact tickerexchangeEq — Exchange code matchValidation:
Postal codes, ZIP codes, etc.
Operators:
eq — Exact codecountryEq — Country codeformatEq — Format type (US=5 digits, UK=varied, etc.)Validation:
Example Query:
query { addresses(where: { zipCode: { countryEq: "US" } }) { id street zipCode }}Geographic latitude (-90 to +90).
Operators:
eq — Exact latituderangeEq — In latitude rangehemisphereEq — North/South hemisphereValidation:
Geographic longitude (-180 to +180).
Operators:
eq — Exact longituderangeEq — In longitude rangeValidation:
Latitude/longitude pairs for geospatial queries.
Operators:
eq — Exact locationdistanceWithin — Distance from point in kilometers (uses PostGIS ST_DWithin)Validation:
Example Query:
query { restaurants(where: { location: { distanceWithin: { latitude: 40.7128 longitude: -74.0060 radiusKm: 5 } } }) { id name location { latitude longitude } }}Database Support:
ST_DWithinIANA timezone identifiers.
Operators:
eq — Exact timezoneoffsetEq — UTC offset (e.g., “UTC-5”)dstAwareEq — Has daylight saving timeValidation:
Example Query:
query { users(where: { timezone: { offsetEq: "UTC-5" } }) { id name timezone }}BCP 47 language locale codes (e.g., “en-US”, “fr-CA”).
Operators:
eq — Exact localelanguageEq — Language code (en, fr, de)regionEq — Region code (US, CA, DE)Validation:
ISO 639 language codes (en, fr, de, etc.).
Operators:
eq — Exact codescriptEq — Script type (Latin, Cyrillic, etc.)Validation:
ISO 3166-1 alpha-2 country codes (US, GB, FR, etc.).
Operators:
eq — Exact country code matchValidation:
Example Query:
query { users(where: { country: { eq: "US" } }) { id name country }}URL-friendly slugs (lowercase, hyphens, no spaces).
Operators:
eq — Exact slugcontains — Partial matchValidation:
[a-z0-9-]+Example Query:
query { articles(where: { slug: { eq: "getting-started" } }) { id title slug }}Semantic versioning (v1.2.3, 1.2.3-alpha, etc.).
Operators:
eq — Exact versionValidation:
SHA-256 hashes (64 hex characters).
Operators:
eq — Exact hashformatEq — Format (hex, base64)Validation:
API authentication keys.
Operators:
eq — Exact keyprefixEq — Key prefix matchlengthEq — Length validationValidation:
Vehicle license plates.
Operators:
eq — Exact platecountryEq — Country/regiontypeEq — Plate type (standard, vanity, etc.)Validation:
Vehicle Identification Numbers.
Operators:
eq — Exact VINwmiEq — World Manufacturer ID (first 3 characters)yearEq — Manufacturing year extractionValidation:
Example Query:
query { vehicles(where: { vin: { wmiEq: "1G1" } }) { id brand vin }}Shipment tracking numbers.
Operators:
eq — Exact numbercarrierEq — Carrier (UPS, FedEx, DHL, etc.)typeEq — Type (standard, express, etc.)Validation:
ISO 6346 shipping container numbers.
Operators:
eq — Exact container IDownerCodeEq — Owner company codeValidation:
IPv4 or IPv6 addresses.
Operators:
eq — Exact IPversionEq — IP version (4 or 6)cidrContains — In CIDR rangeValidation:
Example Query:
query { devices(where: { ipAddress: { versionEq: 4 } }) { id hostname ipAddress }}IPv4 addresses only.
Operators:
eq — Exact IPclassEq — IP class (A, B, C, D, E)isPrivateEq — Private IP rangecidrContains — In CIDR rangeValidation:
IPv6 addresses only.
Operators:
eq — Exact IPscopeEq — Scope (link-local, global, etc.)Validation:
Media Access Control addresses.
Operators:
eq — Exact MACmanufacturerEq — OUI manufacturer codeValidation:
Classless Inter-Domain Routing blocks.
Operators:
eq — Exact CIDRcontainsAddress — IP in rangeoverlaps — CIDR overlapValidation:
Example Query:
query { networks(where: { subnet: { containsAddress: "192.168.1.100" } }) { id subnet }}Network port numbers (0-65535).
Operators:
eq — Exact portserviceEq — Service name (HTTP, SSH, etc.)isReservedEq — Well-known port (0-1023)Validation:
IATA airport codes.
Operators:
eq — Exact codecountryEq — Country codetypeEq — Airport typeValidation:
UN/LOCODE port codes (5-character code).
Operators:
eq — Exact codecountryEq — Country coderegionEq — Region/stateValidation:
Airline flight numbers.
Operators:
eq — Exact numbercarrierEq — Airline coderouteEq — Route (origin-destination)Validation:
Markdown-formatted text content.
Operators:
eq — Exact contentcontains — Substring matchheadingCountEq — Number of headingslinkCountEq — Number of linksValidation:
HTML markup content.
Operators:
eq — Exact contentcontains — Substring matchtagEq — Contains specific tagvalidEq — Well-formed HTMLValidation:
MIME types (e.g., “application/json”).
Operators:
eq — Exact typetypeEq — Main type (application, text, image)subtypeEq — Subtype (json, html, png)Validation:
Example Query:
query { files(where: { mimeType: { typeEq: "image" } }) { id filename mimeType }}Hex color codes (#RRGGBB or #RGB).
Operators:
eq — Exact colorformatEq — Format (hex, rgb, hsl)Validation:
Image file content with metadata.
Operators:
eq — Exact imageformatEq — Image format (JPEG, PNG, WebP)Validation:
File attachments and binary content.
Operators:
eq — Exact filemimetypeEq — MIME type matchsizeRange — File size limitsValidation:
Date intervals with start and end dates.
Operators:
eq — Exact rangeoverlaps — Overlaps with date rangeValidation:
Example Query:
query { projects(where: { timeline: { overlaps: { start: "2024-06-01T00:00:00Z" end: "2024-08-31T23:59:59Z" } } }) { id name }}ISO 8601 durations (e.g., “P1Y2M3DT4H5M6S”).
Operators:
eq — Exact durationwithinRange — Duration within a rangeValidation:
Percentage values (0-100).
Operators:
eq — Exact percentagerangeEq — In rangegte / lte — Greater/less thanValidation:
Example Query:
query { products(where: { discount: { gte: 10, lte: 50 } }) { id name price discount }}All semantic scalar types work seamlessly with FraiseQL’s Rich Filters feature:
query { # Query using rich filter operators users(where: { email: { domainEq: "example.com" } location: { distanceWithin: { latitude: 40.7, longitude: -74.0, radiusKm: 5 } } country: { eq: "US" } }) { id email location { latitude longitude } country }}Validation rules for semantic scalars are configured in TOML:
[fraiseql.validation]# Email domain must be validemail_domain_eq = { pattern = { pattern = "^[a-z0-9]([a-z0-9-]*\\.)*[a-z0-9]([a-z0-9-]*[a-z0-9])?$" } }
# Distance must be within valid rangedistance_within_radius_km = { range = { min = 0, max = 40075 } }
# Country code must be valid ISO 3166-1country_eq = { enum = { values = ["US", "CA", "GB", "FR", "DE"] } }See TOML Configuration - Validation for complete validation documentation.
Rich Filters
Rich Filters — Learn how to use semantic scalars for filtering
TOML Configuration
TOML Configuration — Configure validation rules
Query Operators
Query Operators — Standard operators for all scalars