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

Commit 38b78e6

Browse files
committed
Merge branch 'hotfix/203'
Close #203
2 parents c06036d + 8d3f119 commit 38b78e6

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ All notable changes to this project will be documented in this file, in reverse
1111
`Zend\Validator\CreditCard`, fixing an issue where users were unable to add
1212
new brands as they are created.
1313

14+
- [#203](https://github.com/zendframework/zend-validator/pull/203) adds support
15+
for the new Russian bank card "Mir".
16+
1417
### Changed
1518

1619
- Nothing.

doc/book/validators/credit-card.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The following issuing institutes are accepted:
3333
- Solo
3434
- Visa
3535
- Visa Electron
36+
- Russia Mir
3637

3738
> ### Invalid institutes
3839
>

src/CreditCard.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CreditCard extends AbstractValidator
3131
const MASTERCARD = 'Mastercard';
3232
const SOLO = 'Solo';
3333
const VISA = 'Visa';
34+
const MIR = 'Mir';
3435

3536
const CHECKSUM = 'creditcardChecksum';
3637
const CONTENT = 'creditcardContent';
@@ -72,6 +73,7 @@ class CreditCard extends AbstractValidator
7273
8 => self::SOLO,
7374
9 => self::UNIONPAY,
7475
10 => self::VISA,
76+
11 => self::MIR,
7577
];
7678

7779
/**
@@ -91,6 +93,7 @@ class CreditCard extends AbstractValidator
9193
self::SOLO => [16, 18, 19],
9294
self::UNIONPAY => [16, 17, 18, 19],
9395
self::VISA => [13, 16, 19],
96+
self::MIR => [13, 16],
9497
];
9598

9699
/**
@@ -122,6 +125,7 @@ class CreditCard extends AbstractValidator
122125
'6224', '6225', '6226', '6227', '6228', '62290', '62291',
123126
'622920', '622921', '622922', '622923', '622924', '622925'],
124127
self::VISA => ['4'],
128+
self::MIR => ['2200', '2201', '2202', '2203', '2204'],
125129
];
126130

127131
/**

test/CreditCardTest.php

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testGetMessages()
6060
public function testGetSetType()
6161
{
6262
$validator = new CreditCard();
63-
$this->assertEquals(11, count($validator->getType()));
63+
$this->assertEquals(12, count($validator->getType()));
6464

6565
$validator->setType(CreditCard::MAESTRO);
6666
$this->assertEquals([CreditCard::MAESTRO], $validator->getType());
@@ -253,6 +253,45 @@ public function testMastercardCard($input, $expected)
253253
$this->assertEquals($expected, $validator->isValid($input));
254254
}
255255

256+
/**
257+
* Data provider
258+
*
259+
* @return string[][]|bool[][]
260+
*/
261+
public function mirValues()
262+
{
263+
return [
264+
['3011111111111000', false],
265+
['2031343323344731', false],
266+
['2200312032822721', true],
267+
['2209993834549400', false],
268+
['2204001882200999', true],
269+
['2202000312124573', true],
270+
['2203921957923012', true],
271+
['2204150479254495', true],
272+
['2201123406612104', true],
273+
['2900008996056', false],
274+
['2201969950494', true],
275+
['2201342387927', true],
276+
['2205969950494', false],
277+
];
278+
}
279+
280+
/**
281+
* Test mir card number validity
282+
*
283+
* @dataProvider mirValues
284+
*
285+
* @param string $input
286+
* @param bool $expected
287+
*/
288+
public function testMirCard($input, $expected)
289+
{
290+
$validator = new CreditCard(['type' => CreditCard::MIR]);
291+
292+
$this->assertEquals($expected, $validator->isValid($input));
293+
}
294+
256295
/**
257296
* Test an invalid service class
258297
*

0 commit comments

Comments
 (0)