The Corporation may assign BINs at its discretion from the following block ranges:
Mastercard: 222100 to 272099 and 510000 to 559999
Changes
While the previous validation regex for Mastercard surfaces the first 4-digits for the 2-series numbers and the first 2-digits for the 5-series numbers, it makes sense to strengthen the pattern and add support for the complete 6-digit number range.
I updated our regular expression so that it surfaces:
2-series MasterCard numbers 222100 to 272099
5-series MasterCard numbers 510000 to 559999
I also kept some of the edge case patterns that were part of the old regex (e.g. 677189)
How is this achieved?
Old regex: /^(5[1-5]|677189)|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)/
New regex: /^(5[1-5][0-9]{4}|677189)|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)([0-9]{2})/
For the 2-series numbers, we add the remaining 2 digits ([0-9]{2})
For the 5-series numbers, we add the remaining 4 digits ([0-9]{4})
According to page 73 of the official Mastercard Rules document:
Changes
While the previous validation regex for Mastercard surfaces the first 4-digits for the
2-series numbers
and the first 2-digits for the5-series numbers
, it makes sense to strengthen the pattern and add support for the complete 6-digit number range.I updated our regular expression so that it surfaces:
2-series
MasterCard numbers222100 to 272099
5-series
MasterCard numbers510000 to 559999
I also kept some of the edge case patterns that were part of the old regex (e.g.
677189
)How is this achieved?
/^(5[1-5]|677189)|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)/
/^(5[1-5][0-9]{4}|677189)|^(222[1-9]|2[3-6]\d{2}|27[0-1]\d|2720)([0-9]{2})/
2-series numbers
, we add the remaining 2 digits([0-9]{2})
5-series numbers
, we add the remaining 4 digits([0-9]{4})