credit-card-regex
Advanced tools
Comparing version 1.2.3 to 1.3.0
25
index.js
'use strict'; | ||
var americanExpress = '(?:3[47][0-9]{13})'; | ||
var dinersClub = '(?:3(?:0[0-5]|[68][0-9])[0-9]{11})'; | ||
var discover = '(?:6(?:011|5[0-9]{2})(?:[0-9]{12}))'; | ||
var jcb = '(?:(?:2131|1800|35\\d{3})\\d{11})'; | ||
var maestro = '(?:(?:5[0678]\\d\\d|6304|6390|67\\d\\d)\\d{8,15})'; | ||
var mastercard = '(?:5[1-5][0-9]{14})'; | ||
var visa = '(?:4[0-9]{12})(?:[0-9]{3})?'; | ||
const americanExpress = '(?:3[47][0-9]{13})'; | ||
const dinersClub = '(?:3(?:0[0-5]|[68][0-9])[0-9]{11})'; | ||
const discover = '(?:6(?:011|5[0-9]{2})(?:[0-9]{12}))'; | ||
const jcb = '(?:(?:2131|1800|35\\d{3})\\d{11})'; | ||
const maestro = '(?:(?:5[0678]\\d\\d|6304|6390|67\\d\\d)\\d{8,15})'; | ||
const mastercard = '(?:(?:5[1-5][0-9]{2}|222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12})'; | ||
const visa = '(?:4[0-9]{12})(?:[0-9]{3})?'; | ||
function generate(pattern) { | ||
return function (opts) { | ||
opts = opts || {}; | ||
return opts.exact ? new RegExp('(?:^' + pattern + '$)') : | ||
new RegExp('(["\'])?' + pattern + '\\1', 'g'); | ||
}; | ||
} | ||
const generate = pattern => opts => { | ||
opts = opts || {}; | ||
return opts.exact ? new RegExp(`(?:^${pattern}$)`) : new RegExp(`(["\'])${pattern}\\1`, 'g'); | ||
}; | ||
@@ -18,0 +15,0 @@ module.exports = generate([ |
{ | ||
"name": "credit-card-regex", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "Regular expression for matching credit card numbers", | ||
@@ -13,6 +13,6 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "node test/test.js" | ||
"test": "xo && ava" | ||
}, | ||
@@ -36,4 +36,5 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^0.0.4" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# credit-card-regex [![Build Status](http://img.shields.io/travis/kevva/credit-card-regex.svg?style=flat)](https://travis-ci.org/kevva/credit-card-regex) | ||
# credit-card-regex [![Build Status](https://travis-ci.org/kevva/credit-card-regex.svg?branch=master)](https://travis-ci.org/kevva/credit-card-regex) | ||
@@ -16,3 +16,3 @@ > Regular expression for matching credit card numbers | ||
```js | ||
var creditCardRegex = require('credit-card-regex'); | ||
const creditCardRegex = require('credit-card-regex'); | ||
@@ -47,9 +47,10 @@ creditCardRegex().test('6011881485017922 foo bar'); | ||
#### options.exact | ||
#### options | ||
Type: `boolean` | ||
##### exact | ||
Type: `Boolean`<br> | ||
Default: `false` *(Matches any credit card number in a string)* | ||
Only match an exact string. | ||
Useful with `RegExp#test` to check if a string is a credit card number. | ||
Only match an exact string. Useful with `RegExp#test` to check if a string is a credit card number. | ||
@@ -56,0 +57,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4018
59
2
28