feat(isCreditCard): add RuPay provider support - #2853
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2853 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2599 2599
Branches 658 658
=========================================
Hits 2599 2599 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the visibility here — I want to flag something I should've caught before opening this: #2830 is already open on the same underlying issue (#2829), with @tux-tn having requested changes there on Jul 28. I used an AI assistant to help research BIN coverage before opening this PR, and it caught the overlap. Sharing that analysis here for transparency: Comparing this PR's regex against #2830's: Both cover 606xxx–608xxx similarly, which matches the ranges @tux-tn asked for in review of #2830. The bigger problem: I pulled BINTable's full RuPay listing, and it's not a handful of clean ranges — it's ~3,899 individually registered BINs across 78 pages, genuinely non-contiguous even within the 508xxx block. That means any hand-picked regex (mine included) will keep hitting "you're missing X" feedback until someone processes the full list systematically. Given #2830 was opened first and already has maintainer engagement, I don't think it's right to compete with it. I'm going to close this PR and move this research over to #2830 instead, and offer to help build out a fuller BIN range set there if useful. Apologies for the duplicate — happy to redirect effort wherever's most useful. |
Closes #2829
Adds
rupayas a supportedprovidervalue forisCreditCard, per the issue request.Regex
rupay: /^(?
0-9
|60[6-8][0-9]{13})$/
Covers two BIN ranges independently confirmed against real observed BINs across multiple issuing banks:
508xxx— confirmed via multiple independent BIN-lookup records (Union Bank, PNB, Bank of India, HDFC, Dhanlaxmi, Tamil Nadu State Apex Co-op Bank), all 16-digit RuPay cards.606xxx–608xxx— confirmed via BIN registry data plus independently observed real BINs.Scope note
RuPay also issues co-branded cards using ranges already claimed by other schemes in this file —
65xx(Discover),81xx(UnionPay), and353xxx/356xxx(JCB). These are deliberately excluded here: those ranges belong to the partner network's own registered IIN blocks, so classifying them asrupaywould misattribute numbering ownership and create ambiguous provider checks. Happy to revisit if maintainers want a different approach for co-branded cards.Changes
src/lib/isCreditCard.js: addedrupaypattern to thecardsobjectREADME.md: addedrupayto the documentedprovidervaluestest/validators.test.js: added RuPay numbers to the general valid-card list, plus a dedicatedprovider: 'RuPay'test block (valid + invalid cases)All test numbers are synthetic (correct BIN prefix + length + valid Luhn check digit) — no real card numbers used.
npm testpasses locally: 324 passing, 100% statement/line/function coverage maintained.