From f9dd486b5d3f4d5e0a1784cd7edf85a7263eec36 Mon Sep 17 00:00:00 2001 From: Andy Snell Date: Mon, 5 Dec 2016 00:09:39 -0500 Subject: [PATCH] Update MasterCard BIN Range Updates the credit card validator regular expression for the MasterCard brand to also match 16-digit card numbers starting with 22 - 27. Additionally, updates the unit test for credit cards with two published test cards in the new BIN range. Additional information on the BIN range update can be found at: https://www.mastercard.us/en-us/issuers/get-support/2-series-bin-expansion.html --- src/Valitron/Validator.php | 2 +- tests/Valitron/ValidateTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Valitron/Validator.php b/src/Valitron/Validator.php index b456b52..c5947ae 100644 --- a/src/Valitron/Validator.php +++ b/src/Valitron/Validator.php @@ -725,7 +725,7 @@ class Validator } else { $cardRegex = array( 'visa' => '#^4[0-9]{12}(?:[0-9]{3})?$#', - 'mastercard' => '#^5[1-5][0-9]{14}$#', + 'mastercard' => '#^(5[1-5]|2[2-7])[0-9]{14}$#', 'amex' => '#^3[47][0-9]{13}$#', 'dinersclub' => '#^3(?:0[0-5]|[68][0-9])[0-9]{11}$#', 'discover' => '#^6(?:011|5[0-9]{2})[0-9]{12}$#', diff --git a/tests/Valitron/ValidateTest.php b/tests/Valitron/ValidateTest.php index 459e5c1..ceb10bb 100644 --- a/tests/Valitron/ValidateTest.php +++ b/tests/Valitron/ValidateTest.php @@ -994,7 +994,7 @@ class ValidateTest extends BaseTestCase public function testCreditCardValid() { $visa = array(4539511619543489, 4532949059629052, 4024007171194938, 4929646403373269, 4539135861690622); - $mastercard = array(5162057048081965, 5382687859049349, 5484388880142230, 5464941521226434, 5473481232685965); + $mastercard = array(5162057048081965, 5382687859049349, 5484388880142230, 5464941521226434, 5473481232685965, 2223000048400011, 2223520043560014); $amex = array(371442067262027, 340743030537918, 345509167493596, 343665795576848, 346087552944316); $dinersclub = array(30363194756249, 30160097740704, 38186521192206, 38977384214552, 38563220301454); $discover = array(6011712400392605, 6011536340491809, 6011785775263015, 6011984124619056, 6011320958064251);