|
5 | 5 | * 5791803339, batch #215 item 1, letter B): a currency field carrying `scale` |
6 | 6 | * is refused at parse. The remedy is worded by ruling 5805782503 (batch #218 |
7 | 7 | * 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 |
9 | 9 | * display, and its write allowance stays unconstrained. It names no other key |
10 | 10 | * to carry the value, and the remedy pins below hold both halves: the ruled |
11 | 11 | * wording is present, and the retired pointer is absent. |
@@ -49,7 +49,7 @@ function scaleIssues(result: { success: boolean; error?: { issues: Issue[] } }): |
49 | 49 | */ |
50 | 50 | function expectRuledRemedy(message: string): void { |
51 | 51 | 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'); |
53 | 53 | expect(message).toContain('the field\'s write allowance stays unconstrained'); |
54 | 54 | expect(message).not.toMatch(/currencyConfig|precision/); |
55 | 55 | } |
@@ -138,7 +138,7 @@ describe('CONTROLS: what the refusal must leave alone', () => { |
138 | 138 | const description = (FieldSchema.shape as Record<string, { description?: string }>).scale?.description ?? ''; |
139 | 139 | expect(description).toContain('Applies to `number`, `percent`, `rating` and `slider`'); |
140 | 140 | 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'); |
142 | 142 | expect(description).not.toContain('currencyConfig'); |
143 | 143 | }); |
144 | 144 | }); |
@@ -242,3 +242,27 @@ describe('no registered metadata form OFFERS `scale` on a currency field', () => |
242 | 242 | expect(offered).toEqual([]); |
243 | 243 | }); |
244 | 244 | }); |
| 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 | +}); |
0 commit comments