Skip to content

v0.8.3 — comparison vocabulary

Choose a tag to compare

@tiagoschmitt tiagoschmitt released this 17 Aug 02:39
· 26 commits to main since this release

A contract over an optional parameter should read as one word, not a null-check ritual.

// before
requires(roundedBillableMinutes == null || roundedBillableMinutes >= 0)
requires(ratePercent.greaterThanOrEqualTo(0))

// now
requires(nonNegative(roundedBillableMinutes))
requires(gte(ratePercent, 0))

gt / gte / lt / lte / eq / neq desugar to plain binary comparisons. The runtime typing accepts number | { toNumber() } | null | undefined — structural Decimal support with no dependency — with the semantics present AND in the domain: a nullish value fails the runtime check, and the solver translates the numeric comparison. positive/nonNegative/negative/finite/between are rebuilt on top, so the one-word forms cover optional and Decimal parameters too.

defined(x) is a real TypeScript type guard — requires(defined(x) && x.f >= 0) narrows x for the rest of the predicate — desugaring to x !== null so the existing null machinery applies. neq(b, 0) discharges division-safety obligations.

~320 core tests.