creditcardnumber icon indicating copy to clipboard operation
creditcardnumber copied to clipboard

Mastercard regex coverage issue

Open sesser opened this issue 5 months ago • 0 comments

Issue

The regex pattern used to detect MasterCard excludes a portion of cards (according to the range 2221 - 2720). Specifically, 2230 - 2299. Also, according to MC simplified BIN account range, the min BIN is 222635. You can download the list from https://www.mastercard.us/en-us/business/issuers/get-support/simplified-bin-account-range-table.html

I can't speak to BINs that start with 2221-2225. I have not researched.

  • CardBrand.from("223557******") yields Unknown when it should be MasterCard
  • I think this can be solved with a minor adjustment to the regex pattern

^(?:5[1-5][0-9]{2}|222[1-9]|2[2-6][0-9]{2}|27[01][0-9]|2720)[0-9]*

Environment

Specify the

  • version of Credit Card Number: 4.0.4
  • version of Java: 17
  • operating system and version: Alpine/macOS

sesser avatar Sep 11 '24 17:09 sesser