-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Sync IBAN formats with Swift IBAN registry #48998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9d79010
to
a68399f
Compare
Thanks for the PR. How did you update the file? Would it make sense to commit some generator in the repo to make it easy to sync with upstream? |
@nicolas-grekas, nice idea to keep it up to date. I have a script that parses registry file and generates regexp list. It was merged manually to preserve existing php comments. But I have some doubts:
|
@smelesh We already have similar scripts in some components (parsing the ICU data for instance). So I suggest including such script in the repository. Comments can actually be part of the generated output. The Swift file contains the country name. Regarding experimental countries, I see that the Wikipedia page about IBAN references them with their BBAN format: https://en.wikipedia.org/wiki/International_Bank_Account_Number#cite_ref-48. This is enough to get the IBAN format (as IBAN is 2-letter country code followed by 2-digit checksum followed by BBAN) |
a68399f
to
e76c358
Compare
Sorry for the delay.. Added a script to collect IBAN formats from Wikipedia (experimental) and SWIFT registry (official):
I cannot find how similar scripts are triggered (for example, Since comments in -'AX' => 'FI\d{2}\d{6}\d{7}\d{1}',
+'AX' => 'FI\d{2}\d{3}\d{11}',
-'BF' => 'BF\d{2}\d{23}',
+'BF' => 'BF\d{2}[\dA-Z]{2}\d{22}',
-'BI' => 'BI\d{2}\d{12}',
+'BI' => 'BI\d{2}\d{5}\d{5}\d{11}\d{2}',
-'BJ' => 'BJ\d{2}[A-Z]{1}\d{23}',
+'BJ' => 'BJ\d{2}[\dA-Z]{2}\d{22}',
-'BR' => 'BR\d{2}\d{8}\d{5}\d{10}[A-Z][\dA-Z]',
+'BR' => 'BR\d{2}\d{8}\d{5}\d{10}[A-Z]{1}[\dA-Z]{1}',
+'CF' => 'CF\d{2}\d{23}',
-'CR' => 'CR\d{2}0\d{3}\d{14}',
+'CR' => 'CR\d{2}\d{4}\d{14}',
-'CZ' => 'CZ\d{2}\d{20}',
+'CZ' => 'CZ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\d{12}',
+'ST' => 'ST\d{2}\d{4}\d{4}\d{11}\d{2}',
+'SV' => 'SV\d{2}[A-Z]{4}\d{20}',
+'TD' => 'TD\d{2}\d{23}',
+'TG' => 'TG\d{2}[A-Z]{2}\d{22}',
-'TR' => 'TR\d{2}\d{5}[\dA-Z]{1}[\dA-Z]{16}',
+'TR' => 'TR\d{2}\d{5}\d{1}[\dA-Z]{16}', |
e76c358
to
ac25782
Compare
ac25782
to
3937610
Compare
They are run manually by a contributor once in a while. |
3937610
to
9c5c863
Compare
src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Validator/Resources/bin/sync-iban-formats.php
Outdated
Show resolved
Hide resolved
9c5c863
to
b8a0e25
Compare
b8a0e25
to
d4e3047
Compare
Thank you @smelesh. |
Gathered IBAN formats from IBAN Registry provided by SWIFT.
Some countries don't exist in the registry (Angola, Burkina Faso, Benin, Congo, Ivory Coast, Cameron, Cape Verde, Algeria, Iran, Madagascar, Mali, Mozambique, Senegal). I can't verify the format, but they are marked experimental here: https://www.iban.com/structure
Some formats were changed (Burundi, Costa Rica, Kuwait, Turkey). Is it a BC break?