Skip to content

Commit

Permalink
chore: get everything in sync
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Jun 10, 2020
1 parent adef702 commit 9d05631
Show file tree
Hide file tree
Showing 29 changed files with 536 additions and 55 deletions.
4 changes: 4 additions & 0 deletions es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import isPassportNumber from './lib/isPassportNumber';
import isPort from './lib/isPort';
import isLowercase from './lib/isLowercase';
import isUppercase from './lib/isUppercase';
import isIMEI from './lib/isIMEI';
import isAscii from './lib/isAscii';
import isFullWidth from './lib/isFullWidth';
import isHalfWidth from './lib/isHalfWidth';
Expand Down Expand Up @@ -58,6 +59,7 @@ import isEAN from './lib/isEAN';
import isISIN from './lib/isISIN';
import isISBN from './lib/isISBN';
import isISSN from './lib/isISSN';
import isTaxID from './lib/isTaxID';
import isMobilePhone, { locales as isMobilePhoneLocales } from './lib/isMobilePhone';
import isEthereumAddress from './lib/isEthereumAddress';
import isCurrency from './lib/isCurrency';
Expand Down Expand Up @@ -120,6 +122,7 @@ var validator = {
isSemVer: isSemVer,
isSurrogatePair: isSurrogatePair,
isInt: isInt,
isIMEI: isIMEI,
isFloat: isFloat,
isFloatLocales: isFloatLocales,
isDecimal: isDecimal,
Expand Down Expand Up @@ -178,6 +181,7 @@ var validator = {
normalizeEmail: normalizeEmail,
toString: toString,
isSlug: isSlug,
isTaxID: isTaxID,
isDate: isDate
};
export default validator;
2 changes: 1 addition & 1 deletion es/lib/isCreditCard.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assertString from './util/assertString';
/* eslint-disable max-len */

var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;
var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/;
/* eslint-enable max-len */

export default function isCreditCard(str) {
Expand Down
4 changes: 3 additions & 1 deletion es/lib/isCurrency.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ function currencyRegex(options) {
options.digits_after_decimal.forEach(function (digit, index) {
if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}");
});
var symbol = "(\\".concat(options.symbol.replace(/\./g, '\\.'), ")").concat(options.require_symbol ? '' : '?'),
var symbol = "(".concat(options.symbol.replace(/\W/, function (m) {
return "\\".concat(m);
}), ")").concat(options.require_symbol ? '' : '?'),
negative = '-?',
whole_dollar_amount_without_sep = '[1-9]\\d*',
whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"),
Expand Down
4 changes: 2 additions & 2 deletions es/lib/isDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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 _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; }

Expand Down
10 changes: 7 additions & 3 deletions es/lib/isEmail.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
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 _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; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

Expand Down
4 changes: 2 additions & 2 deletions es/lib/isFQDN.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default function isFQDN(str, options) {

if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
return false;
} // disallow spaces
} // disallow spaces && special characers


if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) {
if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) {
return false;
}
}
Expand Down
1 change: 1 addition & 0 deletions es/lib/isIBAN.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var ibanRegexThroughCountryCode = {
IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
IL: /^(IL[0-9]{2})\d{19}$/,
IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
IS: /^(IS[0-9]{2})\d{22}$/,
IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/,
Expand Down
47 changes: 47 additions & 0 deletions es/lib/isIMEI.js
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;
}
15 changes: 13 additions & 2 deletions es/lib/isJSON.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

import assertString from './util/assertString';
export default function isJSON(str) {
import merge from './util/merge';
var default_json_options = {
allow_primitives: false
};
export default function isJSON(str, options) {
assertString(str);

try {
options = merge(options, default_json_options);
var primitives = [];

if (options.allow_primitives) {
primitives = [null, false, true];
}

var obj = JSON.parse(str);
return !!obj && _typeof(obj) === 'object';
return primitives.includes(obj) || !!obj && _typeof(obj) === 'object';
} catch (e) {
/* ignore */
}
Expand Down
13 changes: 10 additions & 3 deletions es/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ var phones = {
'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
'ar-KW': /^(\+?965)[569]\d{7}$/,
'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/,
'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/,
'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/,
'ar-TN': /^(\+?216)?[2459]\d{7}$/,
'bs-BA': /^((((\+|0{2})3876)|06)[0-6])((?<=4)\d{7}|(?<!4)\d{6})$/,
'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
'de-DE': /^(\+49)?0?1(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
'el-GR': /^(\+?30|0)?(69\d{8})$/,
'en-AU': /^(\+?61|0)4\d{8}$/,
'en-GB': /^(\+?44|0)7\d{9}$/,
Expand All @@ -36,13 +39,17 @@ var phones = {
'en-NZ': /^(\+?64|0)[28]\d{7,9}$/,
'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,
'en-RW': /^(\+?250|0)?[7]\d{8}$/,
'en-SG': /^(\+65)?[89]\d{7}$/,
'en-SG': /^(\+65)?[689]\d{7}$/,
'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/,
'en-TZ': /^(\+?255|0)?[67]\d{8}$/,
'en-UG': /^(\+?256|0)?[7]\d{8}$/,
'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
'en-ZA': /^(\+?27|0)\d{9}$/,
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'en-ZW': /^(\+263)[0-9]{9}$/,
'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/,
'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
'es-CR': /^(\+506)?[2-8]\d{7}$/,
'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
Expand Down Expand Up @@ -72,7 +79,7 @@ var phones = {
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'ne-NP': /^(\+?977)?9[78]\d{8}$/,
'nl-BE': /^(\+?32|0)4?\d{8}$/,
'nl-NL': /^(\+?31|0)6?\d{8}$/,
'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/,
'nn-NO': /^(\+?47)?[49]\d{7}$/,
'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,
'pt-BR': /(?=^(\+?5{2}\-?|0)[1-9]{2}\-?\d{4}\-?\d{4}$)(^(\+?5{2}\-?|0)[1-9]{2}\-?[6-9]{1}\d{3}\-?\d{4}$)|(^(\+?5{2}\-?|0)[1-9]{2}\-?9[6-9]{1}\d{3}\-?\d{4}$)/,
Expand All @@ -87,7 +94,7 @@ var phones = {
'tr-TR': /^(\+?90|0)?5\d{9}$/,
'uk-UA': /^(\+?38|8)?0\d{9}$/,
'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
'zh-CN': /^((\+|00)86)?1([358][0-9]|4[579]|6[67]|7[01235678]|9[189])[0-9]{8}$/,
'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[189])[0-9]{8}$/,
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/
};
/* eslint-enable max-len */
Expand Down
4 changes: 2 additions & 2 deletions es/lib/isNumeric.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assertString from './util/assertString';
var numeric = /^[+-]?([0-9]*[.])?[0-9]+$/;
import { decimal } from './alpha';
var numericNoSymbols = /^[0-9]+$/;
export default function isNumeric(str, options) {
assertString(str);
Expand All @@ -8,5 +8,5 @@ export default function isNumeric(str, options) {
return numericNoSymbols.test(str);
}

return numeric.test(str);
return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? decimal[options.locale] : '.', "])?[0-9]+$")).test(str);
}
6 changes: 6 additions & 0 deletions es/lib/isPassportNumber.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import assertString from './util/assertString';
/**
* Reference:
* https://en.wikipedia.org/ -- Wikipedia
* https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number
* https://countrycode.org/ -- Country Codes
*/

var passportRegexByCountryCode = {
AM: /^[A-Z]{2}\d{7}$/,
// ARMENIA
Expand Down Expand Up @@ -51,6 +53,8 @@ var passportRegexByCountryCode = {
// HUNGARY
IE: /^[A-Z0-9]{2}\d{7}$/,
// IRELAND
IN: /^[A-Z]{1}-?\d{7}$/,
// INDIA
IS: /^(A)\d{7}$/,
// ICELAND
IT: /^[A-Z0-9]{2}\d{7}$/,
Expand Down Expand Up @@ -98,7 +102,9 @@ var passportRegexByCountryCode = {
*/

export default function isPassportNumber(str, countryCode) {
assertString(str);
/** Remove All Whitespaces, Convert to UPPERCASE */

var normalizedStr = str.replace(/\s/g, '').toUpperCase();
return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr);
}
2 changes: 1 addition & 1 deletion es/lib/isSlug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assertString from './util/assertString';
var charsetRegex = /^[^-_](?!.*?[-_]{2,})([a-z0-9\\-]{1,}).*[^-_]$/;
var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/;
export default function isSlug(str) {
assertString(str);
return charsetRegex.test(str);
Expand Down
73 changes: 73 additions & 0 deletions es/lib/isTaxID.js
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;
}
Loading

0 comments on commit 9d05631

Please sign in to comment.