Added RegEx for Insta Payment Card and Maestro Cards#1701
Added RegEx for Insta Payment Card and Maestro Cards#1701metajunaid wants to merge 3 commits intovalidatorjs:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1701 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 102 102
Lines 2029 2029
Branches 457 457
=========================================
Hits 2029 2029
Continue to review full report at Codecov.
|
src/lib/isCreditCard.js
Outdated
|
|
||
| /* eslint-disable max-len */ | ||
| const creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/; | ||
| const creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|((5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15})|(63[7-9][0-9]{13}))$/; |
There was a problem hiding this comment.
(not related to this PR)
Haven't run any test but this regex smells like vulnerable to redos attacks.
There was a problem hiding this comment.
You should add tests in the proper file.
There was a problem hiding this comment.
Test is already passed, you can review this.
Codecov Report
Merging #1701 (90599bc) into master (8c4b3b3) will not change coverage.
The diff coverage is100.00%.@@ Coverage Diff @@ ## master #1701 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 101 101 Lines 2005 2005 Branches 452 452 ========================================= Hits 2005 2005Impacted Files Coverage Δ
src/lib/isCreditCard.js100.00% <100.00%> (ø)
Continue to review full report at Codecov.Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered by Codecov. Last update 8c4b3b3...90599bc. Read the comment docs.
There was a problem hiding this comment.
We should add both successful and failing test cases for the new features introduced in the PR even if the tests are passing
|
Is someone testing this PR? |
|
I have update the PR with tests in commit 4a0239f |
|
Is some one reviewing this PR? |
|
@profnandaa , could you take a look on this PR |
tux-tn
left a comment
There was a problem hiding this comment.
Thank you for your PR @metajunaid and sorry for the late review.
Can you please fix merge conflicts?
|
Hi @tux-tn, I have resolved the conflicts. |
|
@metajunaid can you fix the merge conflicts |
Add validation support for: - Maestro cards (prefixes 5018, 5020, 5038, 6304, 6759, 6761, 6763) - InstaPayment cards (prefixes 637, 638, 639) Both card types are added as individual providers with proper tests. Rescues stale PR validatorjs#1701 (4.5 years old) by rebasing changes onto current code structure. The original PR used a single regex approach, but the codebase has since evolved to use individual provider regexes, so this implementation follows the current pattern. Original author: @avaly Co-Authored-By: Claude Opus 4.6 <[email protected]> Co-Authored-By: avaly <[email protected]>
This PR aims to solve issue #1559.
Added regex to validate Maestro and Insta Payment Card.
RegEx Reference taken from: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841
Insta Payment Card: ^63[7-9][0-9]{13}$
Maestro Card: ^(5018|5020|5038|6304|6759|6761|6763)[0-9]{8,15}$