-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
536 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import assertString from './util/assertString'; | ||
var imeiRegexWithoutHypens = /^[0-9]{15}$/; | ||
var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/; | ||
export default function isIMEI(str, options) { | ||
assertString(str); | ||
options = options || {}; // default regex for checking imei is the one without hyphens | ||
|
||
var imeiRegex = imeiRegexWithoutHypens; | ||
|
||
if (options.allow_hyphens) { | ||
imeiRegex = imeiRegexWithHypens; | ||
} | ||
|
||
if (!imeiRegex.test(str)) { | ||
return false; | ||
} | ||
|
||
str = str.replace(/-/g, ''); | ||
var sum = 0, | ||
mul = 2, | ||
l = 14; | ||
|
||
for (var i = 0; i < l; i++) { | ||
var digit = str.substring(l - i - 1, l - i); | ||
var tp = parseInt(digit, 10) * mul; | ||
|
||
if (tp >= 10) { | ||
sum += tp % 10 + 1; | ||
} else { | ||
sum += tp; | ||
} | ||
|
||
if (mul === 1) { | ||
mul += 1; | ||
} else { | ||
mul -= 1; | ||
} | ||
} | ||
|
||
var chk = (10 - sum % 10) % 10; | ||
|
||
if (chk !== parseInt(str.substring(14, 15), 10)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
|
||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
|
||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
|
||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } | ||
|
||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
|
||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
|
||
import assertString from './util/assertString'; | ||
/** | ||
* An Employer Identification Number (EIN), also known as a Federal Tax Identification Number, | ||
* is used to identify a business entity. | ||
* | ||
* NOTES: | ||
* - Prefix 47 is being reserved for future use | ||
* - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus. | ||
* | ||
* See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes` | ||
* for more information. | ||
*/ | ||
|
||
/** | ||
* Campus prefixes according to locales | ||
*/ | ||
|
||
var campusPrefix = { | ||
'en-US': { | ||
andover: ['10', '12'], | ||
atlanta: ['60', '67'], | ||
austin: ['50', '53'], | ||
brookhaven: ['01', '02', '03', '04', '05', '06', '11', '13', '14', '16', '21', '22', '23', '25', '34', '51', '52', '54', '55', '56', '57', '58', '59', '65'], | ||
cincinnati: ['30', '32', '35', '36', '37', '38', '61'], | ||
fresno: ['15', '24'], | ||
internet: ['20', '26', '27', '45', '46', '47'], | ||
kansas: ['40', '44'], | ||
memphis: ['94', '95'], | ||
ogden: ['80', '90'], | ||
philadelphia: ['33', '39', '41', '42', '43', '46', '48', '62', '63', '64', '66', '68', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '91', '92', '93', '98', '99'], | ||
sba: ['31'] | ||
} | ||
}; | ||
|
||
function getPrefixes(locale) { | ||
var prefixes = []; | ||
|
||
for (var location in campusPrefix[locale]) { | ||
if (campusPrefix[locale].hasOwnProperty(location)) { | ||
prefixes.push.apply(prefixes, _toConsumableArray(campusPrefix[locale][location])); | ||
} | ||
} | ||
|
||
prefixes.sort(); | ||
return prefixes; | ||
} // tax id regex formats for various loacles | ||
|
||
|
||
var taxIdFormat = { | ||
'en-US': /^\d{2}[- ]{0,1}\d{7}$/ | ||
}; | ||
export default function isTaxID(str) { | ||
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; | ||
assertString(str); | ||
|
||
if (!taxIdFormat[locale].test(str)) { | ||
return false; | ||
} | ||
|
||
return getPrefixes(locale).indexOf(str.substr(0, 2)) !== -1; | ||
} |
Oops, something went wrong.