-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(finance): routingNumber now uses real FederalReserveRoutingSymbol from lookup table. #3429
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
base: next
Are you sure you want to change the base?
Conversation
…). Added some conditions to random-seeded finance.routingNumber test. Updated finance test snapshot.
… directive snuck into the index.ts file.
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## next #3429 +/- ##
==========================================
- Coverage 99.97% 99.96% -0.01%
==========================================
Files 2819 2890 +71
Lines 217500 222135 +4635
Branches 953 930 -23
==========================================
+ Hits 217447 222068 +4621
- Misses 53 67 +14
🚀 New features to boost your workflow:
|
matthewmayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a little more detail to the method description
e.g.
"Generates a random routing number."
=>
"Generates a random [ABA routing number](https://en.wikipedia.org/wiki/ABA_routing_transit_number)"
…age for ABA Routing Number. Updated the example string given to reflect the new changes.
|
Done. I used one of the routing numbers from the test snapshot for the example string. |
|
Also, I forgot to mention... I couldn't figure out how to link the original issue to this PR. Sorry I am a bit new to contributing to public github repos. |
|
Also, as I'm sure you've noticed, I skipped any form of testing whether the 2nd group of 2 digits at indexes 2-3 actually matched up with one of the numbers listed in the base finance locale. Of course were I to do that, what I'd really be doing is simply checking if Edit: On a site note, it was interesting to find out that validate.js's Edit 2: After looking at the validator.js source again, I had missed this regex at the top:
Which is checking (though not obviously, of course) that the federal reserve district is correct. Quoted from the wikipedia page on ABA routing numbers:
So that regex is effectively trying to be as exhaustive as possible, almost like an official spec would, except it's a little bizarre for two reasons: One is that it is allowing 000000000, which passes even the check digit validation and is definitely not a valid routing number. So tl;dr the call to |
|
The timeouts happen randomly unfortunately. Even if we increase it to 30s. As for the pnpm update, you might have to update node to the latest (LTS) version. That solved it for me. |
|
Okay that makes me feel better that I didn't do something and break it unwittingly. I'll try again after work today. |
|
Okay I tried again and it didn't time out this time. Pushed up the changes you mentioned. |
|
I was checking back in to see if there was any further action y'all needed me to take to get the PR completed. I see that there was a conflict in the finance definitions file, so I resolved that. Just let me know if there's anything else I should do. Thanks. |
|
@woldaker Thanks for taking action on your own already. Please note that actually merging your PR might take some time. This is not because we don't like your feature but have to carefully consider multiple side effects a feature might have and how well it integrates into the entire API of faker. Lastly, we are obviously working on later major features for the entire Faker project. We also need to consider how new features would integrate in these future plans. |
|
Understood. If I can be of any further help, just say the word, and I'll
keep an eye out.
…On Wed, Mar 12, 2025, 7:00 AM DivisionByZero ***@***.***> wrote:
@woldaker <https://github.com/woldaker> Thanks for taking action on your
own already. Please note that actually merging your PR might take some
time. This is not because we don't like your feature but have to carefully
consider multiple side effects a feature might have and how well it
integrates into the entire API of faker. Lastly, we are obviously working
on later major features for the entire Faker project. We also need to
consider how new features would integrate in these future plans.
So, to summarize, don't worry if your PR is not getting any action for
some time. I appreciate your patience :)
—
Reply to this email directly, view it on GitHub
<#3429 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG2J4DOYSH2LBZIGXJDT77D2UA4YLAVCNFSM6AAAAABYEQEYZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJXHE4DEMBYGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: xDivisionByZerox]*xDivisionByZerox* left a comment
(faker-js/faker#3429)
<#3429 (comment)>
@woldaker <https://github.com/woldaker> Thanks for taking action on your
own already. Please note that actually merging your PR might take some
time. This is not because we don't like your feature but have to carefully
consider multiple side effects a feature might have and how well it
integrates into the entire API of faker. Lastly, we are obviously working
on later major features for the entire Faker project. We also need to
consider how new features would integrate in these future plans.
So, to summarize, don't worry if your PR is not getting any action for
some time. I appreciate your patience :)
—
Reply to this email directly, view it on GitHub
<#3429 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG2J4DOYSH2LBZIGXJDT77D2UA4YLAVCNFSM6AAAAABYEQEYZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJXHE4DEMBYGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
xDivisionByZerox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while, but I've finally had the chance to review your changes. 🎉
Overall, the implementation looks good to me. I have just two minor suggestions - these aren't strictly necessary, but they could help reduce the overall complexity introduced by this PR.
One key point I'd like to discuss with the Faker team is whether the routing number data should be included in the base locale. Since routing numbers are specific to the U.S. by design, users who intentionally select the base locale typically do so to minimize the amount of imported data at startup.
Additionally, the routing number function is a legacy implementation that does not fully align with Faker's current standards. If this function were introduced today, it might be designed with a more general-purpose name - such as bankCode - to accommodate multiple locales. To be clear, I’m not suggesting deprecating the function in favor of a more generic alternative! However, given the tight coupling between its business logic and the American locale, I find it challenging to justify returning values for other locales.
Would it make sense to expose the locale data exclusively to the default en - and thus default - locale? After all, when calling this method from, for example, the de locale, would users really expect an ABA routing number? 🤔 FYI the German equivalent of "routing number" would be the "Bankleitzahl".
Looking forward to your thoughts @faker-js/members!
test/modules/finance.spec.ts
Outdated
|
|
||
| describe('routingNumber()', () => { | ||
| it('should return a string', () => { | ||
| it('should return a string and pass check digit validation', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| it('should return a string and pass check digit validation', () => { | |
| it('should return a valid ABA routing number', () => { |
| @@ -0,0 +1,168 @@ | |||
| // Source: https://www.frbservices.org/resources/fees/check-key-to-routing-numbers.html | |||
| // Last Synced with Source: 2025-03-01 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get the general information based on the commit date. I strongly believe that we would update these values (if required) before merging a PR that changes them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should leave the source URL at the top though right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're saying just remove the // Last Synced comment right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Providing Source is very appreciated. Only the last synced line is obsolete IMO.
|
This is true. US ABA routing numbers are for domestic transfers so that makes total sense to put them into the en_US locale. Internationally, you'd use an IBAN & SWIFT (or some other "routing number" equivalent for the country you're sending it to like GBDSC (UK) or CACPA (Canada)). I can make those changes at some point this week after work. |
Just making sure: |
|
I am so sorry, work got busy and I completely forgot to finish this up! Taking another look at it now... |
|
As an update, I took another look at this last night. I am not even on the same machine anymore that I was last time, so I didn't have pnpm, etc. After reinstalling what I think was everything I needed, pnpm run preflight kept failing with: so I'll have to take another look at it after work today. |
|
Okay I was finally able to get it working. I think it was just that intermittent failure that nobody knows the cause of that was mentioned earlier. I made the changes as suggested here. One thing I must say is that I absolutely agree that the routing number table I added does not belong in base. It belongs in any locale where US is the region. However, that brings up a different issue altogether: when someone from the UK uses faker and calls RoutingNumber(), I would think they should get a GBDSC number (the UK equivalent of the ABA), which doesn't look anything like a US ABA routing number (in the regex/string-format sense. They do both fulfill the same purpose: to identify a specific bank both in brand and in branch location physically). You can find a pretty decent list of various country's bank routing number formats here: https://developer.gs.com/docs/services/transaction-banking/routing-codes/.
EDIT: I realized that that last paragraph would only be true if every country actually had their own RoutingNumber() function. This PR as simply an improvement to the current RoutingNumber() function, which only returns numbers formatted as a US ABA routing number anyway, falls outside the realm of what I had originally said. I think it is still an improvement that doesn't hurt or affect anything else. Let me know your thoughts. |
Big edit right there. I appreciate the effort you put into thinking about this feature in a wider sense. As pointed out in my previous comment the But the change you present is targeted on the validity of the current resulting values of the I don't know when I or one for the team members will have time to review this PR again, but I didn't want to leave you hanging without at least an answer since I saw that you had a previous issue with your development setup, to which no one responded to. |


Fixes #3290
finance.routingNumber is now comprised as follows:
Digits 0-3 = Pulled from locales/base/finance/federal_reserve_routing_symbol.ts
Digits 4-7 = Random
Digit 8 = Check digit. Calculated from the previous 8 digits as before.
Added more test conditions to the randomly-seeded finance.routingNumber test.