Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename isSecurityCodeValid to isCVVValid #76

Merged
merged 2 commits into from
Jan 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/balanced.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ var cc = {
}
return null;
},
isSecurityCodeValid:function (cardNumber, cvv) {
isCVVValid:function (cardNumber, cvv) {
var cardType = cc.cardType(cardNumber);
if (!cardType) {
return false;
Expand All @@ -234,6 +234,10 @@ var cc = {

return false;
},
// Deprecated. Aliased to isCVVValid
isSecurityCodeValid:function (cardNumber, securityCode) {
return cc.isCVVValid(cardNumber, securityCode);
},
isExpiryValid:function (expiryMonth, expiryYear) {
if (!expiryMonth || !expiryYear) {
return false;
Expand Down Expand Up @@ -261,7 +265,7 @@ var cc = {
if (!cc.isCardNumberValid(number)) {
errors.push(buildErrorObject('number', 'Invalid field [number] - "' + number + '" is not a valid credit card number'));
}
if (typeof cvv !== 'undefined' && cvv !== null && !cc.isSecurityCodeValid(number, cvv)) {
if (typeof cvv !== 'undefined' && cvv !== null && !cc.isCVVValid(number, cvv)) {
errors.push(buildErrorObject('cvv', 'Invalid field [cvv] - "' + cvv + '" is not a valid credit card security code'));
}
if (!cc.isExpiryValid(expiryMonth, expiryYear)) {
Expand Down
16 changes: 15 additions & 1 deletion test/unit/cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ test('cardType', function (assert) {
});

test('isSecurityCodeValid', function (assert) {
var tests = [
{
number: '4111111111111111',
csc: 123,
expected: true
}
];

for(var i = 0; i < tests.length; i++) {
assert.equal(balanced.card.isSecurityCodeValid(tests[i].number, tests[i].csc), tests[i].expected, "Test #" + (i + 1));
}
});

test('isCVVValid', function (assert) {
var tests = [
{
number: '4111111111111111',
Expand Down Expand Up @@ -303,7 +317,7 @@ test('isSecurityCodeValid', function (assert) {
];

for(var i = 0; i < tests.length; i++) {
assert.equal(balanced.card.isSecurityCodeValid(tests[i].number, tests[i].csc), tests[i].expected, "Test #" + (i + 1));
assert.equal(balanced.card.isCVVValid(tests[i].number, tests[i].csc), tests[i].expected, "Test #" + (i + 1));
}
});

Expand Down