From 535201d062a96826ec3f34a4301b8ceb40edebab Mon Sep 17 00:00:00 2001 From: yu2971512385-ui <287936273+yu2971512385-ui@users.noreply.github.com> Date: Sun, 18 Oct 2026 11:22:25 +0800 Subject: [PATCH] fix(isISO4217): sync the currency list with the ISO 4217 register The list was taken from Wikipedia and has not kept up. Checked against ISO 4217 list one as published on 2026-09-17, it accepts four codes the register has withdrawn and rejects three it assigns: removed ANG replaced by XCG on 2025-03-31 removed BGN Bulgaria adopted the euro on 2026-01-01 removed SLL replaced by SLE on 2022-04-01 removed ZWL replaced by ZWG on 2024-04-05 added XAD Arab Accounting Dinar added XCG Caribbean Guilder added ZWG Zimbabwe Gold The README documents isISO4217 as checking for an officially assigned code, and the suite already asserts that the withdrawn HRK and CUC are invalid, so the four removals follow the behaviour the validator already claims. The source comment now points at the register itself rather than at Wikipedia, with the date of the list it was checked against. Co-Authored-By: Claude Opus 5 (1M context) --- src/lib/isISO4217.js | 13 +++++++------ test/validators.test.js | 7 +++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/lib/isISO4217.js b/src/lib/isISO4217.js index bbca596a9..5f89e0e5a 100644 --- a/src/lib/isISO4217.js +++ b/src/lib/isISO4217.js @@ -1,9 +1,10 @@ import assertString from './util/assertString'; -// from https://en.wikipedia.org/wiki/ISO_4217 +// from https://www.six-group.com/en/products-services/financial-information/data-standards.html +// (ISO 4217 list one, the currencies and funds in current use), published 2026-09-17 const validISO4217CurrencyCodes = new Set([ - 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', - 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', + 'AED', 'AFN', 'ALL', 'AMD', 'AOA', 'ARS', 'AUD', 'AWG', 'AZN', + 'BAM', 'BBD', 'BDT', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP', 'BYN', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF', 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUP', 'CVE', 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EGP', 'ERN', 'ETB', 'EUR', @@ -20,14 +21,14 @@ const validISO4217CurrencyCodes = new Set([ 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', 'RWF', - 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLE', 'SLL', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', + 'SAR', 'SBD', 'SCR', 'SDG', 'SEK', 'SGD', 'SHP', 'SLE', 'SOS', 'SRD', 'SSP', 'STN', 'SVC', 'SYP', 'SZL', 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'USN', 'UYI', 'UYU', 'UYW', 'UZS', 'VED', 'VES', 'VND', 'VUV', 'WST', - 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', + 'XAD', 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC', 'XBD', 'XCD', 'XCG', 'XDR', 'XOF', 'XPD', 'XPF', 'XPT', 'XSU', 'XTS', 'XUA', 'XXX', 'YER', - 'ZAR', 'ZMW', 'ZWL', + 'ZAR', 'ZMW', 'ZWG', ]); export default function isISO4217(str) { diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..ababe1c2c 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -12668,6 +12668,9 @@ describe('Validators', () => { 'USD', 'VED', 'SLE', + 'XAD', + 'XCG', + 'ZWG', ], invalid: [ '', @@ -12681,6 +12684,10 @@ describe('Validators', () => { 'euro', 'HRK', 'CUC', + 'ANG', + 'BGN', + 'SLL', + 'ZWL', ], }); });