Operators on native types
A native type says which operators work on its values, and only those work. A duration adds, subtracts, scales and compares. A semver compares by version. An email takes none, so $email + 1 stops with a message that says so. The editor reads the same list, so it knows what 1h + 30m gives, and warns about $version * 2 before the script runs.
<let name="wait" type="duration" value="1h30m" />
<echo value="$wait + 15m" /> <!-- 1h45m -->
<echo value="$wait * 2" /> <!-- 3h -->
<echo value="$wait / 30m // 3" />
<echo value="90s < 2m" /> <!-- true -->
<echo value="@now() + $wait > @now()" /> <!-- true -->
<let name="v" type="semver" value="1.4.2" />
<echo value="$v < '1.10.0'" /> <!-- true: versions compare by number, not as text -->
<let name="price" type="money" value="'GBP 9.50'" />
<echo value="$price * 3" /> <!-- GBP 28.50 -->
<echo value="$price + 'GBP 0.50'" /> <!-- GBP 10.00 -->
<let name="home" type="ip" value="10.0.0.1" />
<echo value="$home + 5" /> <!-- 10.0.0.6 -->
<echo value="$home in '10.0.0.0/8'" /> <!-- true -->$wait: duration = 1h30m
echo $wait + 15m // 1h45m
echo $wait * 2 // 3h
echo $wait / 30m // 3
echo 90s < 2m // true
echo @now() + $wait > @now() // true
$v: semver = 1.4.2
echo $v < '1.10.0' // true: versions compare by number, not as text
$price: money = 'GBP 9.50'
echo $price * 3 // GBP 28.50
echo $price + 'GBP 0.50' // GBP 10.00
$home: ip = 10.0.0.1
echo $home + 5 // 10.0.0.6
echo $home in '10.0.0.0/8' // trueText next to a native value is read as that type, so $wait + '15m' and $v < '1.10.0' work. Joining text with + still joins text: 'Wait ' + $wait.
| Type | Operators | < > and sorting |
for |
False when |
|---|---|---|---|---|
duration |
duration + duration, duration - duration, duration * number, number * duration, duration / number (a duration), duration / duration (a number), duration % duration, date + duration, duration + date, date - duration, -duration, date..date step duration (step 1mo gives each month) |
by length (1mo and 30d have no order) |
0s |
|
money |
money + money (mixed currencies need a directed rate), money - money (one currency), money * number, number * money, money / number (rounded to the currency's smallest unit), money / money (a number), -money |
by amount, in one currency | the amount is 0 | |
ip |
ip + number, ip - number, ip - ip (a number), ip..ip step number |
by address, IPv4 first | ||
cidr |
ip in cidr, cidr in cidr |
by network, then prefix | its addresses (up to 65,536) | |
semver |
by version: 1.0.0-rc.1 < 1.0.0 < 1.10.0. == ignores build metadata. |
|||
port |
the number operators (a port is a number) | by number | ||
email, handle, uuid, url, domain, mac, slug, mime, hex, country, currency, locale, timezone |
alphabetical | |||
password |
none, and no == either: use ->verify() |
|||
regex, base64, jwt, json, phone, cron, color, iban, card |
none |
A type without an order stops < and ->sort() with a message. Sort by a key instead: $colors->sort(by: .luminance). A few types compare by meaning rather than spelling: json ignores spacing and key order, base64 ignores padding, cron compares the times it runs (@daily == '0 0 * * *'), and color compares the colour (orange == '#ffa500').
Ranges of dates step by a duration, and default to a day:
<let name="start" value="'2026-11-23'->to_date()" />
<for each="day" in="$start..$start + 5d">
<echo value="$day->format('ddd')" /> <!-- Mon to Fri -->
</for>$start = '2026-11-23'->to_date()
for day in $start..$start + 5d {
echo $day->format('ddd') // Mon to Fri
}Lists of one native type
A list whose items are all one native type has that type's list methods as well as every list's. ->only() and ->without() take a filter the type declares, or a type name, written without quotes:
<let name="versions" type="semver[]" value="[1.0.0, 1.1.0-rc.1, 1.1.0-beta.2, 1.0.10]" />
<echo value="$versions->only(releases)" /> <!-- 1.0.0, 1.0.10 -->
<echo value="$versions->without(release_candidates)" /> <!-- 1.0.0, 1.1.0-beta.2, 1.0.10 -->
<echo value="$versions->latest()" /> <!-- 1.0.10, the highest release -->
<echo value="$versions->max()" /> <!-- 1.1.0-rc.1, prereleases included -->
<let name="fees" type="money[]" value="['GBP 9.50', 'GBP 0.50']" />
<echo value="$fees->total()" /> <!-- GBP 10.00 -->
<let name="a" type="semver" value="2.0.0" />
<let name="mixed" value="[$a, 'hello', 3]" />
<echo value="$mixed->only(semver)->only(releases)" /> <!-- 2.0.0 -->
<echo value="$mixed->without(string)" /> <!-- 2.0.0, 3 -->
<echo value="'hello'->is_a(string)" /> <!-- true -->$versions: semver[] = [1.0.0, 1.1.0-rc.1, 1.1.0-beta.2, 1.0.10]
echo $versions->only(releases) // 1.0.0, 1.0.10
echo $versions->without(release_candidates) // 1.0.0, 1.1.0-beta.2, 1.0.10
echo $versions->latest() // 1.0.10, the highest release
echo $versions->max() // 1.1.0-rc.1, prereleases included
$fees: money[] = ['GBP 9.50', 'GBP 0.50']
echo $fees->total() // GBP 10.00
$a: semver = 2.0.0
$mixed = [$a, 'hello', 3]
echo $mixed->only(semver)->only(releases) // 2.0.0
echo $mixed->without(string) // 2.0.0, 3
echo 'hello'->is_a(string) // true| Type | Filters | List methods |
|---|---|---|
semver |
releases, prereleases, release_candidates, betas, alphas |
->latest() |
money |
->total() |
An explicitly typed empty list keeps its element type. Filtering also keeps the type when every item is removed. For example, $mixed->only(semver)->only(releases) returns [] when no versions match. On an empty semver[], ->latest() returns null. On an empty money[], ->total() returns null because there is no currency to sum.
A list of a native type can be written without quotes too, as above: [1.0.0, 1.1.0-rc.1].