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

Hotfix/6278 #6927

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/Zend/Validator/CreditCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CreditCard extends AbstractValidator
self::DINERS_CLUB => array(14),
self::DINERS_CLUB_US => array(16),
self::DISCOVER => array(16),
self::JCB => array(16),
self::JCB => array(15, 16),
self::LASER => array(16, 17, 18, 19),
self::MAESTRO => array(12, 13, 14, 15, 16, 17, 18, 19),
self::MASTERCARD => array(16),
Expand All @@ -108,7 +108,7 @@ class CreditCard extends AbstractValidator
'62290', '62291', '622920', '622921', '622922', '622923',
'622924', '622925', '644', '645', '646', '647', '648',
'649', '65'),
self::JCB => array('3528', '3529', '353', '354', '355', '356', '357', '358'),
self::JCB => array('1800', '2131', '3528', '3529', '353', '354', '355', '356', '357', '358'),
self::LASER => array('6304', '6706', '6771', '6709'),
self::MAESTRO => array('5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763',
'6764', '6765', '6766'),
Expand Down
32 changes: 32 additions & 0 deletions tests/ZendTest/Validator/CreditCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,38 @@ public function testConstructionWithOptions($input, $expected)
$this->assertEquals($expected, $validator->isValid($input));
}

public function jcbValues()
{
return array(
array('3566003566003566', true),
array('3528000000000007', true),
array('3528000000000007', true),
array('3528000000000007', true),
array('3088185545477406', false),
array('3158854390756173', false),
array('3088936920428541', false),
array('213193692042852', true),
array('180012362524156', true),
);
}

/**
* Test JCB number validity
*
* @dataProvider jcbValues
* @group issue-6278
*/
public function testJcbCard($input, $expected)
{
$validator = new CreditCard(
array(
'type' => CreditCard::JCB
)
);

$this->assertEquals($expected, $validator->isValid($input));
}

/**
* Test an invalid service class
*
Expand Down