-
-
Notifications
You must be signed in to change notification settings - Fork 933
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
finance.iban does not create valid iban #1832
Comments
i cant provide a full list of valid bank-codes. maybe there is some online source (API?) for it? |
TL;DR; This is a very hard task to accomplish and it would require constant maintenance to keep the correctness. IMHO, implementing country specific checks are, probably, not worth doing as it would only be required for very specific use cases. Here is a longer explanation, why it is not worth doing IBAN has generic format (I'll use the one from this issue):
Each BBAN has a format, which is different for each country. Here is a page that very well illustrates what format each country is using. In this case BBAN is divided to following codes:
Taken from service description, it checks account checksum (explanation taken from service);
Which, translates to something like this (used google translation):
Some countries have their own specific additional validation logic to check if account is correct. Here is page form oracle docs explaining it. Furthermore, to pass online service checks, it would require to use real life data, which is constantly changing. This is what ibancalculator service is doing. It actually checks if the sort code 15339441 (first 8 symbols of bban) exists in the National Competent Authorities in charge of banking lists. In this case it is bundesbank.de. DE NCA allows to download the list of code - link to the page or search it via web interface. My knowledge in this field is a little bit outdated, but couple years ago there were some NCAs that would only allowed to get the lists via web interface without the possibility to download them in any other format. Even heard some talks that people had to scrape some NCAs pages in order to get the list and keep it updated. Given the nature of NCAs (part of the government), I do not expect that changes are quickly applied in their systems. But, I could be wrong as there were few grand changes in EU banking sector that could have improved how the things works. So, honestly, if you have a specific case, where you would need to check on real life data, it would probably make more sense to take the record from NCA list and construct the IBAN account around it, rather than implementing all this logic into the library. But again, this is only my opinion ;) |
There is a Website, which generates valid IBANs. Maybe you can work together with them to integrate that logic into Faker. That would be awesome Mentioned Website is: |
the source code is here http://www.randomiban.com/static/mapp4.js and is pretty messy i tend to agree with @b-pagis that i think this is out of scope for Faker. I would instead consider updating the documentation to explain that the method creates plausible but potentially invalid IBANs. |
Pre-Checks
Describe the bug
when using:
"finance.iban" the iban is always invalid.
In my case i used:
faker.finance.iban(false, 'DE')
and got for example:
DE88 1533 9441 3800 0600 27
but even the iban mentioned in the documentation are not valid:
https://fakerjs.dev/api/finance.html#iban
to check, if a iban is valid you can use:
https://www.ibancalculator.com/iban_validieren.html
Minimal reproduction code
https://stackblitz.com/edit/faker-js-demo-ngipzd?embed=1&file=index.html
Additional Context
No response
Environment Info
Which module system do you use?
Used Package Manager
npm
The text was updated successfully, but these errors were encountered: