Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 2a1e784

Browse files
committed
Merge branch 'hotfix/110' into develop
Forward port #110
2 parents a5dfe95 + 5b9b801 commit 2a1e784

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
### Added
2626

27-
- Nothing.
27+
- [#110](https://github.com/zendframework/zend-validator/pull/110) adds new
28+
Mastercard 2-series BINs
2829

2930
### Deprecated
3031

src/CreditCard.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ class CreditCard extends AbstractValidator
112112
self::LASER => ['6304', '6706', '6771', '6709'],
113113
self::MAESTRO => ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
114114
'6764', '6765', '6766', '6772'],
115-
self::MASTERCARD => ['51', '52', '53', '54', '55'],
115+
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229',
116+
'223', '224', '225', '226', '227', '228', '229',
117+
'23', '24', '25', '26', '271', '2720',
118+
'51', '52', '53', '54', '55'],
116119
self::SOLO => ['6334', '6767'],
117120
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214',
118121
'62215', '62216', '62217', '62218', '62219', '6222', '6223',

test/CreditCardTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,44 @@ public function testJcbCard($input, $expected)
213213
$this->assertEquals($expected, $validator->isValid($input));
214214
}
215215

216+
/**
217+
* Data provider
218+
*
219+
* @return string[][]|bool[][]
220+
*/
221+
public function mastercardValues()
222+
{
223+
return [
224+
['4111111111111111', false],
225+
['5011642326344731', false],
226+
['5130982099822729', true],
227+
['2220993834549400', false],
228+
['2221006548643366', true],
229+
['2222007329134574', true],
230+
['2393923057923090', true],
231+
['2484350479254492', true],
232+
['2518224476613101', true],
233+
['2659969950495289', true],
234+
['2720992392889757', true],
235+
['2721008996056187', false],
236+
];
237+
}
238+
239+
/**
240+
* Test mastercard number validity
241+
*
242+
* @dataProvider mastercardValues
243+
*
244+
* @param string $input
245+
* @param bool $expected
246+
*/
247+
public function testMastercardCard($input, $expected)
248+
{
249+
$validator = new CreditCard(['type' => CreditCard::MASTERCARD]);
250+
251+
$this->assertEquals($expected, $validator->isValid($input));
252+
}
253+
216254
/**
217255
* Test an invalid service class
218256
*

0 commit comments

Comments
 (0)