Skip to content

fix(nb-NO,sv-SE,fi-FI): guard scale ceilings in the Nordic group#361

Merged
TylerVigario merged 1 commit into
mainfrom
fix/nordic-scale-ceilings
Jun 4, 2026
Merged

fix(nb-NO,sv-SE,fi-FI): guard scale ceilings in the Nordic group#361
TylerVigario merged 1 commit into
mainfrom
fix/nordic-scale-ceilings

Conversation

@TylerVigario
Copy link
Copy Markdown
Collaborator

Thirteenth in the fix-then-gate series. Three Nordic languages, each verified individually (distinct ceilings).

ceiling decimal guard SCALES
nb-NO 10³⁰ yes [scaleIndex-2], 8 entries
sv-SE 10²⁷ yes [scaleIndex-1] from tusen, 8 entries
fi-FI 10¹⁸ no [scaleIndex-2], 4 entries

All three: ordinal (cardinal + suffix) and currency build on the cardinal, so one MAX_CARDINAL guards every form. fi-FI reads its fraction digit-by-digit, so a long decimal has no ceiling and is correctly not guarded (a 40-digit decimal still converts); nb/sv spell the fraction via integerToWords, so they are.

Verification

Per locale: well-formed string or RangeError across ±10⁴⁰; integer/ordinal/decimal boundaries confirm ceil−1 ok / ceil throws. Existing fixtures green, lint clean, 269 tests.

🤖 Generated with Claude Code

Three distinct languages, each with its own ceiling (verified individually):

- nb-NO: 10^30 (SCALES indexed [scaleIndex-2], 8 entries). Decimal guarded.
- sv-SE: 10^27 (SCALES indexed [scaleIndex-1] from 'tusen', 8 entries).
  Decimal guarded.
- fi-FI: 10^18 (SCALES [scaleIndex-2], 4 entries). NO decimal guard —
  Finnish reads the fraction digit-by-digit (40-digit decimal still
  converts).

All three: ordinal (cardinal + suffix) and currency build on the cardinal,
so a single MAX_CARDINAL guards all forms. Entry-point pattern; ceiling
derived from each SCALES table.

Verified per locale (well-formed or RangeError; integer/ordinal/decimal
boundaries); full suite green (269).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 4, 2026 16:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the “fix-then-gate” series by adding scale-ceiling enforcement for three Nordic locales so that values at/above each language’s largest supported magnitude throw a uniform RangeError (via tooLargeError) instead of producing malformed output.

Changes:

  • Add per-locale MAX_CARDINAL / MAX_CARDINAL_EXPONENT constants derived from each locale’s SCALES table.
  • Add entry-point guards in toCardinal, toOrdinal, and toCurrency to throw tooLargeError(...) when out of range (and additionally guard the decimal significant digits for nb-NO and sv-SE where decimals use the scale builder).
  • Import and use the shared tooLargeError helper in the updated locales.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/sv-SE.js Adds a 10^27 ceiling derived from SCALES and enforces it at public entry points (including decimal significant digits).
src/nb-NO.js Adds a 10^30 ceiling derived from SCALES and enforces it at public entry points (including decimal significant digits).
src/fi-FI.js Adds a 10^18 ceiling derived from SCALES and enforces it at public entry points (integer only; decimals are per-digit and intentionally unguarded).

@TylerVigario TylerVigario merged commit 02cd569 into main Jun 4, 2026
8 checks passed
@TylerVigario TylerVigario deleted the fix/nordic-scale-ceilings branch June 4, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants