diff --git a/README.md b/README.md index a205c06..f5c07a1 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ > A simple credit cards validation library in JavaScript. -creditcard.js - ## Install You can [download the zip file](https://github.com/contaazul/creditcard.js/archive/master.zip) or use NPM and Bower. diff --git a/assets/images/credit-card-logo.png b/assets/images/credit-card-logo.png deleted file mode 100644 index bf15f8b..0000000 Binary files a/assets/images/credit-card-logo.png and /dev/null differ diff --git a/bower.json b/bower.json index be4a57d..63a3587 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "creditcard.js", "description": "A simple library for credit-card validation in JavaScript", "main": "dist/creditcard.min.js", - "version": "2.0.3", + "version": "2.1.0", "authors": [ "@ContaAzul" ], diff --git a/dist/creditcard.js b/dist/creditcard.js index 60e25fd..5af10e0 100644 --- a/dist/creditcard.js +++ b/dist/creditcard.js @@ -1,5 +1,5 @@ /*! - * creditcard.js v2.0.3 + * creditcard.js v2.1.0 * Created by @ContaAzul. * * Licensed MIT. @@ -53,7 +53,7 @@ var CreditCard = function () { key: 'isSecurityCodeValid', value: function isSecurityCodeValid(number, code) { var brand = this.getCreditCardNameByNumber(number); - var numberLength = undefined; + var numberLength = void 0; numberLength = brand === 'Amex' ? 4 : 3; var regex = new RegExp('^[0-9]{' + numberLength + '}$'); @@ -69,6 +69,8 @@ var CreditCard = function () { m = parseInt(m, 10); y = parseInt(y, 10); + if (isNaN(m) || isNaN(y)) return false; + if (m < 1 || m > 12) return false; return !(y < 1000 || y >= 3000); @@ -107,7 +109,7 @@ var CREDIT_CARD_LIST = [{ regexpFull: '^50[0-9]{14,17}$' }, { name: 'Mastercard', - regexpFull: '^5[1-5][0-9]{14}$' + regexpFull: '^(5[1-5][0-9]{14}|2221[0-9]{12}|222[2-9][0-9]{12}|22[3-9][0-9]{13}|2[3-6][0-9]{14}|27[01][0-9]{13}|2720[0-9]{12})$' }, { name: 'Visa', regexpFull: '^4[0-9]{12}(?:[0-9]{3})?$' diff --git a/dist/creditcard.min.js b/dist/creditcard.min.js index 045ad75..9ecaff3 100644 --- a/dist/creditcard.min.js +++ b/dist/creditcard.min.js @@ -1,7 +1,7 @@ /*! - * creditcard.js v2.0.3 + * creditcard.js v2.1.0 * Created by @ContaAzul. * * Licensed MIT. */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.CreditCard=e()}}(function(){var e,r,n;return function e(r,n,t){function i(a,o){if(!n[a]){if(!r[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(u)return u(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[a]={exports:{}};r[a][0].call(s.exports,function(e){var n=r[a][1][e];return i(n?n:e)},s,s.exports,e,r,n,t)}return n[a].exports}for(var u="function"==typeof require&&require,a=0;at||t>12?!1:!(1e3>i||i>=3e3)}}]),e}();r.exports=o},{"./creditCardList":2,"./helpers/luhn":3}],2:[function(e,r,n){"use strict";function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,r){for(var n=0;n0&&i%10===0}}]),e}();r.exports=u},{}]},{},[1])(1)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,r.CreditCard=e()}}(function(){var e,r,n;return function e(r,n,t){function i(a,o){if(!n[a]){if(!r[a]){var l="function"==typeof require&&require;if(!o&&l)return l(a,!0);if(u)return u(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var s=n[a]={exports:{}};r[a][0].call(s.exports,function(e){var n=r[a][1][e];return i(n?n:e)},s,s.exports,e,r,n,t)}return n[a].exports}for(var u="function"==typeof require&&require,a=0;a12)&&!(i<1e3||i>=3e3))}}]),e}();r.exports=o},{"./creditCardList":2,"./helpers/luhn":3}],2:[function(e,r,n){"use strict";function t(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,r){for(var n=0;n0&&i%10===0}}]),e}();r.exports=u},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/package.json b/package.json index 20ccefc..e67edca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "creditcard.js", - "version": "2.0.3", + "version": "2.1.0", "description": "A simple library for credit-card validation in JavaScript", "main": "dist/creditcard.min.js", "repository": "ContaAzul/creditcard.js", diff --git a/src/creditCardList.js b/src/creditCardList.js index 0c05a89..e51761a 100644 --- a/src/creditCardList.js +++ b/src/creditCardList.js @@ -19,8 +19,7 @@ const CREDIT_CARD_LIST = [ regexpFull: '^50[0-9]{14,17}$' }, { name: 'Mastercard', - regexpFull: '^5[1-5][0-9]{14}$' - //regexpFull: '^(5[1-5][0-9]{14}|2221[0-9]{12}|222[2-9][0-9]{12}|22[3-9][0-9]{13}|2[3-6][0-9]{14}|27[01][0-9]{13}|2720[0-9]{12})$' //After October + regexpFull: '^(5[1-5][0-9]{14}|2221[0-9]{12}|222[2-9][0-9]{12}|22[3-9][0-9]{13}|2[3-6][0-9]{14}|27[01][0-9]{13}|2720[0-9]{12})$' }, { name: 'Visa', regexpFull: '^4[0-9]{12}(?:[0-9]{3})?$'