Insurance pricing example using the published MoonDMN package
moon version
moon update
# Already recorded in moon.mod; these reproduce the registry declarations:
moon add sundaysebasidian-byte/moondmn@0.2.2
moon add moonbitlang/x@0.5.7
moon fmt
moon fmt --check
moon check --deny-warn --target native
moon test --deny-warn --target native
moon check --deny-warn --target js
moon test --deny-warn --target js
moon check --deny-warn --target wasm-gc
moon test --deny-warn --target wasm-gc
python3 scripts/validate-model.py
python3 scripts/test-cli.py
python3 scripts/check-personal-data.py
moon run cmd/main --target native -- samples/standard.json
moon package --list
moon package
moon publish --dry-run{"risk":"standard","basePremium":400,"surcharges":0,"annualPremium":400,"validUntil":"2026-01-31","coverageEnd":"2027-01-01"}| Field | Accepted value |
|---|---|
| age | Integer, 18 through 80 inclusive |
| claims | Integer, 0 through 10 inclusive |
| insuredValue | Number, greater than 0 and at most 1000000 |
| paymentMonthly | Boolean |
| startDate | Valid FEEL date string, e.g. 2026-01-01 |
| Error code | Meaning |
|---|---|
| E_USAGE | Missing input filename or extra command-line arguments |
| E_IO | Input file cannot be read |
| E_INPUT_JSON | The initial JSON parser rejects malformed JSON |
| E_INPUT | Wrong object shape, types, business ranges or invalid date |
| E_JSON | MoonDMN's strict JSON reader rejects the input, including duplicate keys that pass the initial shape checks |
| E_DECIMAL_RANGE | A JSON number exceeds MoonDMN's decimal128/exponent limits |
| E_DECIMAL_SYNTAX | MoonDMN rejects a numeric token, including one longer than its 10000-character limit |
| E_DATE_RANGE | Quote date arithmetic exceeds MoonDMN's supported year range |
| Other MoonDMN codes | Model parsing and FEEL evaluation failures retain their upstream codes |
| Decision | Hand-derived rule |
|---|---|
| Risk (FIRST) | Claims >=3: high, rate .04; otherwise age <25: young, .03; otherwise age >=65: senior, .025; otherwise standard, .02 |
| BasePremium | BKM calculates decimal(insuredValue * Risk.rate, 2) (half-even) |
| Surcharges (COLLECT SUM) | Add 50 for any claims, 24 for monthly payments, 100 for value >50000; explicit default 0 when no rule matches |
| AnnualPremium | decimal(sum([BasePremium, Surcharges]), 2) |
| Quote | Return decision results plus startDate + P30D validity and startDate + P1Y coverage end |
Install
Download zipInsurance pricing example using the published MoonDMN package