Skip to content

feat: add ISO 4217 currencies dictionary - #22

Merged
jan-kubica merged 2 commits into
mainfrom
feat/currencies-dictionary
Mar 21, 2026
Merged

jan-kubica merged 2 commits into
mainfrom
feat/currencies-dictionary

Conversation

@jan-kubica

@jan-kubica jan-kubica commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add packages/data/config/currencies.json with 155 active ISO 4217 currency codes (plus recently withdrawn codes like HRK for historical document support) and 22 common currency symbols
  • Data file is sorted via sort-json.ts (codes alphabetically, symbols by Unicode codepoint)
  • Available for future use to dynamically build the monetary amount regex pattern, replacing the current hardcoded USD|EUR|GBP|... alternation

Notes

Wiring this into the regex detector requires making the detector async (similar to date-months.json), which is a larger change tracked separately.

Test plan

  • Verify JSON is valid and sorted
  • Verify no existing tests break

Open with Devin

Add currencies.json with all ISO 4217 currency codes and common
currency symbols for monetary amount detection. This data file
is available for future use to replace hardcoded currency codes
in the monetary amount regex pattern (requires async detector
refactor).
@greptile-apps

greptile-apps Bot commented Mar 21, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds packages/data/config/currencies.json, a new static data file containing 155 ISO 4217 currency codes (plus recently withdrawn codes such as HRK for historical document support) and 22 common currency symbols, intended to eventually replace the hardcoded USD|EUR|GBP|... alternation in the monetary-amount regex detector in packages/anonymize/src/detectors/regex.ts. The file is not yet wired into any detector — that follow-up work is tracked separately.

Key points:

  • JSON structure is valid; codes are alphabetically sorted and symbols are sorted by Unicode codepoint, consistent with the project's sort-json.ts tooling.
  • The _comment field documents the intended scope (active + recently withdrawn), following the pattern established by date-months.json.
  • ZWG (Zimbabwe Gold, the active ISO 4217 code for Zimbabwe since April 2024) is absent from the codes array, while its withdrawn predecessor ZWL is present. ZWL is also not mentioned in _comment alongside HRK, leaving its inclusion undocumented.
  • No existing code is modified; no tests are broken by this purely additive change.

Confidence Score: 4/5

  • Safe to merge — purely additive data file with no runtime impact, but one active currency code (ZWG) is missing.
  • The change is a single, inert JSON data file not yet consumed by any detector, so there is no risk of a runtime regression. The score is 4 rather than 5 because ZWG (Zimbabwe Gold, active since April 2024) is absent while its withdrawn predecessor ZWL is included without documentation, which would silently produce an incomplete currency list when the file is eventually wired into the regex detector.
  • packages/data/config/currencies.json — verify ZWG inclusion and ZWL withdrawal documentation before the file is wired into the monetary detector.

Important Files Changed

Filename Overview
packages/data/config/currencies.json New data file adding 155 ISO 4217 currency codes and 22 currency symbols. JSON is valid, codes are alphabetically sorted, symbols are sorted by Unicode codepoint, and a _comment documents scope. One issue: ZWG (Zimbabwe Gold, active since April 2024) is absent while its withdrawn predecessor ZWL is present and undocumented as withdrawn.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["currencies.json\n(codes + symbols)"] -->|"future async load\n(tracked separately)"| B["monetary-amount detector\npackages/anonymize/src/detectors/regex.ts"]
    B -->|"currently hardcoded"| C["USD|EUR|GBP|CZK|PLN\n|HUF|CHF|SEK|NOK|DKK\n|RON|JPY|CNY"]
    B -->|"future: dynamic alternation\nbuilt from codes array"| D["AED|AFN|ALL|…|ZWG\n(155+ codes)"]
    style A fill:#d4edda,stroke:#28a745
    style C fill:#fff3cd,stroke:#ffc107
    style D fill:#cce5ff,stroke:#004085
Loading

Last reviewed commit: "fix: document scope,..."

greptile-apps[bot]

This comment was marked as resolved.

- Update _comment to clarify list includes recently withdrawn codes
  (e.g. HRK) for historical document support
- Add ₾ (U+20BE, Georgian Lari) to symbols list
- Codes count is 155, not 158 as originally stated
@jan-kubica
jan-kubica marked this pull request as ready for review March 21, 2026 05:40
@jan-kubica
jan-kubica merged commit f91a2fd into main Mar 21, 2026
1 check passed
@jan-kubica
jan-kubica deleted the feat/currencies-dictionary branch March 21, 2026 05:40

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

"XCD",
"XOF",
"XPF",
"YER",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 ZWG (Zimbabwe Gold) missing; ZWL is withdrawn

ZWL (Zimbabwean Dollar, 4th) was formally withdrawn when Zimbabwe introduced the Zimbabwe Gold (ZWG) in April 2024 — roughly the same timeline as HRK. As of today ZWG is the active ISO 4217 code for Zimbabwe, yet it is absent from the codes array while its superseded predecessor ZWL is present.

Since the intent is "active + recently withdrawn for historical document support", ZWG should be added to the list as an active currency, and ZWL should ideally be documented alongside HRK in the _comment field to make clear it is a recently withdrawn entry (or removed if only HRK-era withdrawals are in scope).

Suggested fix:

Suggested change
"YER",
"ZWG",
"ZWL"

And update _comment to reference ZWL alongside HRK, e.g.:

"_comment": "ISO 4217 currency codes (active + recently withdrawn, e.g. HRK, ZWL, for historical document support) and common currency symbols for monetary amount detection."

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.

1 participant