Skip to content

Commit c073310

Browse files
committed
docs(spec): name CLDR fraction digits, not the ISO 4217 minor unit, as a currency amount's decimal places
The currency `scale` refusal, the inline grid column refusal, the `currencyConfig` decimal-places prescription, the `precision` and `scale` describes, the semantic upgrade-guide entries, the docs pages and the ui mirror strings and docblocks said a currency amount's decimal places are its ISO 4217 minor unit. The platform's digit source is CLDR's fraction digits (`CURRENCY_FRACTION_DIGITS`, and `Intl` on every display face), which differ from ISO 4217 for sixteen codes (IQD 0 against 3, and fifteen codes 0 against 2). Words only: no table value, refusal arm, rule id or path moves. Claude-Session: https://claude.ai/code/session_01L6bhgWFZUMBKFD9Lcwt4DU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4bf9a2d commit c073310

43 files changed

Lines changed: 121 additions & 95 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎content/docs/data-modeling/field-types.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ what a record-currency amount refuses.
234234
{ name: 'price', label: 'Price', type: 'currency', currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD' } }
235235
```
236236

237-
A currency amount's decimal places are its currency's ISO 4217 minor unit
238-
(2 for USD, 0 for JPY, 3 for KWD), not a field setting, and they are declared
239-
nowhere. A `currency` field takes no `scale`, and `currencyConfig` has no
237+
A currency amount's decimal places are its currency's CLDR fraction digits
238+
(2 for USD, 0 for JPY, 3 for KWD; not ISO 4217's minor units, which differ for
239+
sixteen codes such as IQD, 0 in CLDR and 3 in ISO 4217: see
240+
[Currency fields](/docs/data-modeling/currency)), not a field setting, and they
241+
are declared nowhere. A `currency` field takes no `scale`, and `currencyConfig` has no
240242
decimal-places key: publish-time validation refuses `scale` on the field and
241243
`currencyConfig.precision` (removed in `@objectstack/spec` 17.5.0 — no renderer
242244
or runtime ever read it), each with a prescription to delete the key. The

‎content/docs/data-modeling/validation-rules.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ These properties apply to **all** field types and are validated by the base `Fie
157157
| `currencyConfig.currencyField` | `string` | — | Required under `record` and refused under the other two modes: a `text` field of the same object declaring `valueDomain: 'iso_4217_currency'` (the object refuses a pointer at anything else). A write that leaves a record-mode amount holding a value beside a blank code is refused, `ERR_CURRENCY_CODE_REQUIRED` / 400 |
158158
| `currencyConfig.homeAmount` | `object` | — | Optional under `record` and refused under the other two modes: the stored home-currency projection, three pointers into the same object, all required — `field` (a `dynamic`-mode `currency` field, `readonly: true`), `rateDate` (a `date` or `datetime` field, the document date that picks the rate) and `rateField` (a `number` field, `readonly: true`). See [Declaring the home amount](/docs/data-modeling/currency#declaring-the-home-amount) |
159159

160-
**Default constraints:** Stored as a **bare number** (a finite numeric scalar — `valueSchemaFor` routes `currency` to `z.number().finite()`); there is no `{ value, currency }` envelope on the value path. The amount never carries its currency code: under `dynamic` and `fixed` the code is field configuration, carried by `currencyConfig` above, and under `record` it is the value of the record's own code field, an ordinary `text` column judged by its `valueDomain` ([Currency fields](/docs/data-modeling/currency)). Decimal places are the currency's ISO 4217 minor unit (2 for USD, 0 for JPY, 3 for KWD) and are declared nowhere — `currencyConfig` has no decimal-places key (`currencyConfig.precision` is refused, with a prescription to delete it), and the field-level `precision` is the total digit count, never compared with the currency.
160+
**Default constraints:** Stored as a **bare number** (a finite numeric scalar — `valueSchemaFor` routes `currency` to `z.number().finite()`); there is no `{ value, currency }` envelope on the value path. The amount never carries its currency code: under `dynamic` and `fixed` the code is field configuration, carried by `currencyConfig` above, and under `record` it is the value of the record's own code field, an ordinary `text` column judged by its `valueDomain` ([Currency fields](/docs/data-modeling/currency)). Decimal places are the currency's CLDR fraction digits (2 for USD, 0 for JPY, 3 for KWD; not ISO 4217's minor units, which differ for sixteen codes such as IQD) and are declared nowhere — `currencyConfig` has no decimal-places key (`currencyConfig.precision` is refused, with a prescription to delete it), and the field-level `precision` is the total digit count, never compared with the currency.
161161

162162
### `percent`
163163

‎content/docs/protocol/objectql/schema.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ fields:
290290
| `valueDomain` | `string` | `text` | Standard the written value must belong to: `iana_time_zone`, `iso_4217_currency` or `iso_3166_alpha2` (the closed vocabulary shared with settings specifiers). A `record`-mode `currency` amount's code field is a `text` field declaring `iso_4217_currency` ([Currency fields](/docs/data-modeling/currency)). |
291291
| `min` | `number` | `number`, `currency` | Minimum numeric value. |
292292
| `max` | `number` | `number`, `currency` | Maximum numeric value. |
293-
| `scale` | `number` | `number`, `percent`, `rating`, `slider` | Decimal places, enforced on writes. Refused on `currency` — delete it there: a currency amount's decimal places are its currency's, so its ISO 4217 minor unit decides the display. |
293+
| `scale` | `number` | `number`, `percent`, `rating`, `slider` | Decimal places, enforced on writes. Refused on `currency` — delete it there: a currency amount's decimal places are its currency's, so its CLDR fraction digits decide the display. |
294294
| `precision` | `number` | `number`, `currency` | Total digits (including scale). |
295295
| `currencyConfig` | `object` | `currency` | Where the amount's currency comes from: `currencyMode` `dynamic` (the tenant default, the default), `fixed` (with `defaultCurrency`) or `record` (with `currencyField`, the sibling code field, and optionally `homeAmount`, the stored home-currency projection: `field` a `dynamic`-mode `currency` field, `rateDate` a `date` or `datetime` field, `rateField` a `number` field — see [Declaring the home amount](/docs/data-modeling/currency#declaring-the-home-amount)). |
296296
| `options` | `array` | `select`, `multiselect` | List of valid values. |

‎content/docs/protocol/objectql/types.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ revenue:
3030
# - Store a bare number, never a currency code beside it: it shows in
3131
# the tenant default currency (plain if none is set), one fixed on the
3232
# field, or each record's code in a declared sibling field, at that
33-
# currency's ISO 4217 decimal places
33+
# currency's CLDR fraction digits
3434
# - UI shows currency symbol
3535
# - Validate numeric precision
3636
# - Format for display ($1,234.56)
@@ -340,7 +340,7 @@ been removed from the spec.
340340
record's code is judged by its field's `valueDomain: iso_4217_currency`, so
341341
only ISO 4217 codes pass there
342342
- No decimal-places setting: an amount's decimal places are its currency's
343-
ISO 4217 minor unit. The field-level `precision` is the amount's **total**
343+
CLDR fraction digits (not ISO 4217's minor units). The field-level `precision` is the amount's **total**
344344
digit count (a DECIMAL(18,2) amount declares `precision: 18`), refused on
345345
write when exceeded, with the amount's written decimals counted in it
346346

‎packages/objectql/src/validation/record-validator.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ function validateOne(
15251525
// Maintainer ruling 5791803339 (batch #215 item 1, letter B): `scale` is
15261526
// retired from the `currency` type. `FieldSchema` refuses the key there at
15271527
// parse, with the remedy ruling 5805782503 (batch #218 item 2, letter 乙)
1528-
// words (delete the key; the currency's ISO 4217 minor unit decides its
1528+
// words (delete the key; the currency's CLDR fraction digits decide its
15291529
// display), so no authored currency field declares it any more — and this
15301530
// branch stops reading `def.scale` for the type, so a declaration that
15311531
// reaches here anyway (a stored field that predates the refusal, a

‎packages/spec/liveness/field.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@
429429
"verifiedAt": "2026-09-27",
430430
"evidenceScope": "in-repo",
431431
"evidence": "ui/packages/i18n/src/currency.ts:60 reads field.currencyConfig.defaultCurrency ONLY when currencyConfig.currencyMode is 'fixed' — the second step of resolveFieldCurrency's precedence chain; a 'dynamic' config, or one naming no mode, skips it for the tenant default localization.currency; ui/packages/fields/src/widgets/CurrencyField.tsx:55 calls resolveFieldCurrency and applies the resolved code at :91 through formatAmount, which passes it to Intl.NumberFormat via formatDisplayNumber — measured objectui @25c7d584",
432-
"note": "NARROWED 2026-10-28 (#27157, ruling 6464202770 on #27119, Q2 = X): `defaultCurrency` lost its `'CNY'` default and is required under `fixed` (a `fixed` config without a code is refused with the prescription); a `dynamic` config parses with no `defaultCurrency`, and stored rows lose the baked code through the ADR-0087 conversion `currency-config-dynamic-default-currency-removed`. The reader is unchanged and was re-read on this date: ui/packages/i18n/src/currency.ts#resolveFieldCurrency still takes the code only under `fixed`, so a `dynamic` config that no longer carries `CNY` displays exactly as before. Verdict unchanged: LIVE. RE-CITED 2026-09-27 (#20126): since objectui#10461 the reader takes defaultCurrency only under currencyMode 'fixed', and the chain no longer cites the date/datetime-semantics ADR, which never names currency; line pointers moved with it (currency.ts :32 → :60, CurrencyField.tsx :45/:51 → :55/:91). Verdict unchanged: LIVE. RE-CITED 2026-08-10 (#7133/#7142): the old pointer 'packages/fields/src/index.tsx:469' now lands in formatRelativeDays, a date-phrase helper with no currency involvement — the resolver moved to @object-ui/i18n and packages/fields/src/currency.ts:14 only re-exports it, which is why the old line drifted onto unrelated code rather than disappearing. Verdict unchanged: LIVE, and now cited at both the reader that consumes the key and the widget that applies the resolved currency. The removed `currencyConfig.precision` (#19992; packages/spec/src/data/field.zod.ts; moved out of spec source, #23434): the widget's one width is the currency's ISO 4217 minor unit, objectui @b9814b334 packages/fields/src/widgets/CurrencyField.tsx#CurrencyField through objectui @b9814b334 packages/fields/src/widgets/number-format.ts#currencyDisplayWidth over objectui @b9814b334 packages/fields/src/currency.ts#currencyFractionDigits, and no objectui code reads `currencyConfig.precision`; re-read 2026-10-15, first cited sha-less (the source then named `currencyFractionDigits(currency)` as the widget's own line)."
432+
"note": "NARROWED 2026-10-28 (#27157, ruling 6464202770 on #27119, Q2 = X): `defaultCurrency` lost its `'CNY'` default and is required under `fixed` (a `fixed` config without a code is refused with the prescription); a `dynamic` config parses with no `defaultCurrency`, and stored rows lose the baked code through the ADR-0087 conversion `currency-config-dynamic-default-currency-removed`. The reader is unchanged and was re-read on this date: ui/packages/i18n/src/currency.ts#resolveFieldCurrency still takes the code only under `fixed`, so a `dynamic` config that no longer carries `CNY` displays exactly as before. Verdict unchanged: LIVE. RE-CITED 2026-09-27 (#20126): since objectui#10461 the reader takes defaultCurrency only under currencyMode 'fixed', and the chain no longer cites the date/datetime-semantics ADR, which never names currency; line pointers moved with it (currency.ts :32 → :60, CurrencyField.tsx :45/:51 → :55/:91). Verdict unchanged: LIVE. RE-CITED 2026-08-10 (#7133/#7142): the old pointer 'packages/fields/src/index.tsx:469' now lands in formatRelativeDays, a date-phrase helper with no currency involvement — the resolver moved to @object-ui/i18n and packages/fields/src/currency.ts:14 only re-exports it, which is why the old line drifted onto unrelated code rather than disappearing. Verdict unchanged: LIVE, and now cited at both the reader that consumes the key and the widget that applies the resolved currency. The removed `currencyConfig.precision` (#19992; packages/spec/src/data/field.zod.ts; moved out of spec source, #23434): the widget's one width is the currency's CLDR fraction digits, objectui @b9814b334 packages/fields/src/widgets/CurrencyField.tsx#CurrencyField through objectui @b9814b334 packages/fields/src/widgets/number-format.ts#currencyDisplayWidth over objectui @b9814b334 packages/fields/src/currency.ts#currencyFractionDigits, and no objectui code reads `currencyConfig.precision`; re-read 2026-10-15, first cited sha-less (the source then named `currencyFractionDigits(currency)` as the widget's own line)."
433433
},
434434
"dimensions": {
435435
"status": "live",

‎packages/spec/src/conversions/entries/18/currency-config-precision-removed.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { type Dict, isDict, stripKeys } from '../shared.js';
1919
* ever read (#19992, ADR-0049 enforce-or-remove; triage direction REMOVE under
2020
* ruling 乙 on #19910, 「a currency's decimal places are the currency's, not a
2121
* setting」). objectui's `CurrencyField` derives an amount's decimal places from
22-
* the currency's ISO 4217 minor unit and never looked at the key; its only
22+
* the currency's CLDR fraction digits and never looked at the key; its only
2323
* reader was its own #7918 ISO 4217 contradiction check, which policed a width
2424
* nothing applied.
2525
*
@@ -50,7 +50,7 @@ const currencyConfigPrecisionRemoved: MetadataConversion = {
5050
surface: 'object.fields.*.currencyConfig.precision',
5151
summary:
5252
"currency field key 'currencyConfig.precision' removed (ADR-0049 — no renderer or "
53-
+ 'runtime ever read it: an amount\'s decimal places are its currency\'s ISO 4217 minor unit, '
53+
+ 'runtime ever read it: an amount\'s decimal places are its currency\'s CLDR fraction digits, '
5454
+ 'derived from the currency itself. Its ISO 4217 contradiction check and the default `2` '
5555
+ 'baked into parse output went with it; the field-level `precision` is a total digit count '
5656
+ 'and is untouched)',

‎packages/spec/src/data/currency-precision-iso4217.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
* #19992 — `currencyConfig.precision` is REMOVED (ADR-0049 enforce-or-remove).
99
* It was declared, validated against ISO 4217 by the #7918 rule, and baked to
1010
* `2` into parse output by the #11423 `.overwrite()` — and read by nothing:
11-
* objectui's `CurrencyField` derives the width from the currency's ISO 4217
12-
* minor unit. The #7918 / #11423 blocks that used to open this file pinned a
11+
* objectui's `CurrencyField` derives the width from the currency's CLDR
12+
* fraction digits. The #7918 / #11423 blocks that used to open this file pinned a
1313
* rule over a key nobody honoured; they are replaced below by the retirement's
1414
* own pins (the refusal, its two alias spellings, the parse output, and the
1515
* ADR-0087 conversion at rest).
@@ -57,7 +57,7 @@ describe('`currencyConfig.precision` is removed: refused with the prescription,
5757
expect(issue.message).toContain(RETIREMENT_LEAD);
5858
expect(issue.message).toContain('no renderer or runtime ever read it');
5959
expect(issue.message).toContain(
60-
"a currency amount's decimal places are its currency's ISO 4217 minor unit (2 for USD, 0 for JPY, 3 for KWD)",
60+
"a currency amount's decimal places are its currency's CLDR fraction digits (2 for USD, 0 for JPY, 3 for KWD)",
6161
);
6262
expect(issue.message).toContain('Do not move the number to the field-level `precision`');
6363
expect(issue.message).toContain('Delete the key.');
@@ -105,7 +105,7 @@ describe('`currencyConfig.precision` is removed: refused with the prescription,
105105
expect(issue.message).toContain(
106106
`\`currencyConfig.${key}\` is not a currency configuration key, and nothing replaces it`,
107107
);
108-
expect(issue.message).toContain("ISO 4217 minor unit (2 for USD, 0 for JPY, 3 for KWD)");
108+
expect(issue.message).toContain("CLDR fraction digits (2 for USD, 0 for JPY, 3 for KWD)");
109109
expect(issue.message).toContain('Delete the key.');
110110
expect(issue.message).not.toContain('Did you mean');
111111
// Never keys: no conversion strips them, so the message names no command.

‎packages/spec/src/data/field-currency-scale-refused.test.ts‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* 5791803339, batch #215 item 1, letter B): a currency field carrying `scale`
66
* is refused at parse. The remedy is worded by ruling 5805782503 (batch #218
77
* item 2, letter 乙 — a currency's decimal places are the currency's, not a
8-
* setting): delete the key; the currency's ISO 4217 minor unit decides its
8+
* setting): delete the key; the currency's CLDR fraction digits decide its
99
* display, and its write allowance stays unconstrained. It names no other key
1010
* to carry the value, and the remedy pins below hold both halves: the ruled
1111
* wording is present, and the retired pointer is absent.
@@ -49,7 +49,7 @@ function scaleIssues(result: { success: boolean; error?: { issues: Issue[] } }):
4949
*/
5050
function expectRuledRemedy(message: string): void {
5151
expect(message.startsWith('`scale` is not valid on a `currency` field — delete the key.')).toBe(true);
52-
expect(message).toContain('the currency\'s ISO 4217 minor unit (2 for USD, 0 for JPY, 3 for KWD) decides how the amount displays');
52+
expect(message).toContain('the currency\'s CLDR fraction digits (2 for USD, 0 for JPY, 3 for KWD) decide how the amount displays');
5353
expect(message).toContain('the field\'s write allowance stays unconstrained');
5454
expect(message).not.toMatch(/currencyConfig|precision/);
5555
}
@@ -138,7 +138,7 @@ describe('CONTROLS: what the refusal must leave alone', () => {
138138
const description = (FieldSchema.shape as Record<string, { description?: string }>).scale?.description ?? '';
139139
expect(description).toContain('Applies to `number`, `percent`, `rating` and `slider`');
140140
expect(description).toContain('REFUSED on a `currency` field — delete it there');
141-
expect(description).toContain('the currency\'s ISO 4217 minor unit decides how the amount displays');
141+
expect(description).toContain('the currency\'s CLDR fraction digits decide how the amount displays');
142142
expect(description).not.toContain('currencyConfig');
143143
});
144144
});
@@ -242,3 +242,27 @@ describe('no registered metadata form OFFERS `scale` on a currency field', () =>
242242
expect(offered).toEqual([]);
243243
});
244244
});
245+
246+
// ────────────────────────────────────────────────────────────────────────────
247+
// The digit source the refusal names is the one the platform uses.
248+
//
249+
// `CURRENCY_FRACTION_DIGITS` is a CLDR `currencyData` snapshot and every
250+
// display face asks `Intl` (ICU, the same CLDR data), so an amount's decimal
251+
// places are the currency's CLDR fraction digits. ISO 4217's minor unit is a
252+
// different number for sixteen codes (IQD 0 against 3; AFN, ALL, COP, HUF,
253+
// IDR, IRR, KPW, LAK, LBP, MGA, MMK, PKR, SOS, SYP and YER 0 against 2), so a
254+
// refusal naming ISO 4217 tells an IQD author to expect three decimals the
255+
// platform never shows.
256+
// ────────────────────────────────────────────────────────────────────────────
257+
258+
describe('the currency `scale` refusal names CLDR fraction digits, not the ISO 4217 minor unit', () => {
259+
it('the refusal and the `scale` describe say CLDR and no longer say "ISO 4217 minor unit"', () => {
260+
const [issue] = scaleIssues(FieldSchema.safeParse({ name: 'amount', label: 'Amount', type: 'currency', scale: 2 }));
261+
expect(issue?.code).toBe('custom');
262+
expect(issue?.message).toContain('CLDR fraction digits');
263+
expect(issue?.message).not.toContain('ISO 4217 minor unit');
264+
const description = (FieldSchema.shape as Record<string, { description?: string }>).scale?.description ?? '';
265+
expect(description).toContain('CLDR fraction digits');
266+
expect(description).not.toContain('ISO 4217 minor unit');
267+
});
268+
});

‎packages/spec/src/data/field-scale.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('resolveFieldScale', () => {
5555
});
5656

5757
it('declares NO width for currency — the key is retired from the type', () => {
58-
// `currency` resolves its cell's fraction digits from ISO 4217 minor units
58+
// `currency` resolves its cell's fraction digits from CLDR's count
5959
// and can no longer declare this key at all (retired from the type,
6060
// refused at parse).
6161
expect(resolveFieldScale({ type: 'currency' })).toBeUndefined();

0 commit comments

Comments
 (0)