Skip to content

Commit

Permalink
Bumping version to 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Mrak committed May 15, 2015
1 parent 4b9698e commit 03c6ac4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.0.1
=====

- The npm module now includes built files under `dist/`.

2.0.0
=====

Expand Down
34 changes: 15 additions & 19 deletions dist/card-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@ function isEmptyObject(object) {
}

function cardNumber(value) {
var cardType, valid;
var cardType, valid, i, maxLength;

if (isNumber(value)) {
value = String(value);
Expand All @@ -2116,32 +2116,28 @@ function cardNumber(value) {

if (!/^\d*$/.test(value)) { return verification(null, false, false); }

// TODO: Just letting these go here as validPartials
// The optimal solution would be to have a separate
// set of regexes for partial validations
cardType = getCardType(value);
if (isEmptyObject(cardType)) { return verification(null, false, false); }

// Discover cannot be determined until we have 4 digits
if (value.length <= 3 && value[0] === '6') {
return verification(null, true, false);
if (cardType.type === 'unionpay') { // UnionPay is not Luhn 10 compliant
valid = true;
} else {
valid = luhn10(value);
}

// Non-discover cards
if (value.length <= 1 && /^(5|4|3)/.test(value)) { return verification(null, true, false); }
for (i = 0; i < cardType.lengths.length; i++) {
if (cardType.lengths[i] === value.length) {
return verification(cardType, valid, valid);
}
}

cardType = getCardType(value);
if (isEmptyObject(cardType)) { return verification(null, false, false); }
maxLength = Math.max.apply(null, cardType.lengths);

// Recognized as card but not long enough yet: validPartial
if (value.length < cardType.length) {
if (value.length < maxLength) {
return verification(cardType, true, false);
}

if (value.length > cardType.length) {
return verification(cardType, false, false);
}

valid = luhn10(value);
return verification(cardType, valid, valid);
return verification(cardType, false, false);
}

module.exports = cardNumber;
Expand Down
2 changes: 1 addition & 1 deletion dist/card-validator.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "card-validator",
"version": "2.0.0",
"version": "2.0.1",
"description": "A library for validating credit card fields",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 03c6ac4

Please sign in to comment.