Skip to content

Added RegEx for Insta Payment Card and Maestro Cards #1701

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

metajunaid
Copy link

@metajunaid metajunaid commented Jul 20, 2021

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}$

@codecov
Copy link

codecov bot commented Jul 20, 2021

Codecov Report

Merging #1701 (04525ea) into master (13651ea) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1701   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          102       102           
  Lines         2029      2029           
  Branches       457       457           
=========================================
  Hits          2029      2029           
Impacted Files Coverage Δ
src/lib/isCreditCard.js 100.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 13651ea...04525ea. Read the comment docs.

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}))$/;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not related to this PR)
Haven't run any test but this regex smells like vulnerable to redos attacks.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedeci Could you please test this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add tests in the proper file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is already passed, you can review this.

Codecov Report

Merging #1701 (90599bc) into master (8c4b3b3) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1701   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          101       101           
  Lines         2005      2005           
  Branches       452       452           
=========================================
  Hits          2005      2005           

Impacted Files Coverage Δ
src/lib/isCreditCard.js 100.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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add both successful and failing test cases for the new features introduced in the PR even if the tests are passing

@metajunaid
Copy link
Author

Is someone testing this PR?

@metajunaid
Copy link
Author

I have update the PR with tests in commit 4a0239f

@metajunaid
Copy link
Author

Is some one reviewing this PR?

@metajunaid
Copy link
Author

@profnandaa , could you take a look on this PR

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your PR @metajunaid and sorry for the late review.
Can you please fix merge conflicts?

@tux-tn tux-tn added 🧹 needs-update For PRs that need to be updated before landing and removed needs-tests labels Oct 4, 2021
metajunaid added a commit to metajunaid/validator.js that referenced this pull request Oct 5, 2021
@metajunaid
Copy link
Author

Hi @tux-tn, I have resolved the conflicts.

@metajunaid metajunaid requested a review from tux-tn October 12, 2021 06:35
@rubiin rubiin added the mc-to-land Just merge-conflict standing between the PR and landing. label Jun 26, 2023
@rubiin rubiin removed the 🧹 needs-update For PRs that need to be updated before landing label May 10, 2024
@rubiin
Copy link
Member

rubiin commented May 10, 2024

@metajunaid can you fix the merge conflicts

@pano9000 pano9000 mentioned this pull request Sep 7, 2024
4 tasks
@bmonish bmonish mentioned this pull request Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 first-pr mc-to-land Just merge-conflict standing between the PR and landing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants