Skip to content

Commit

Permalink
fix: sync src/lib with lib
Browse files Browse the repository at this point in the history
Some PRs (e.g. #1010 and #1017) haven't been compiled
properly.
  • Loading branch information
chriso committed May 23, 2019
1 parent 63e4c78 commit 330ad51
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 196 deletions.
3 changes: 2 additions & 1 deletion lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
var phones = {
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
'ar-KW': /^(\+?965)[569]\d{7}$/,
Expand Down Expand Up @@ -48,6 +48,7 @@ var phones = {
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
Expand Down
1 change: 1 addition & 0 deletions lib/isPostalCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var patterns = {
GR: /^\d{3}\s?\d{2}$/,
HR: /^([1-5]\d{4}$)/,
HU: fourDigit,
ID: fiveDigit,
IL: fiveDigit,
IN: sixDigit,
IS: threeDigit,
Expand Down
206 changes: 12 additions & 194 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,191 +40,6 @@ function _typeof(obj) {
return _typeof(obj);
}

function _toArray(arr) {
return _arrayWithHoles(arr) || _iterableToArray(arr) || _nonIterableRest();
}

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

function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}

function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}

function _toPrimitive(input, hint) {
if (typeof input !== "object" || input === null) return input;
var prim = input[Symbol.toPrimitive];

if (prim !== undefined) {
var res = prim.call(input, hint || "default");
if (typeof res !== "object") return res;
throw new TypeError("@@toPrimitive must return a primitive value.");
}

return (hint === "string" ? String : Number)(input);
}

function _toPropertyKey(arg) {
var key = _toPrimitive(arg, "string");

return typeof key === "symbol" ? key : String(key);
}

function _addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];

if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}

keys.push(element.key);
}

function _fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
}

function _toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return _toArray(elementObjects).map(function (elementObject) {
var element = _toElementDescriptor(elementObject);

_disallowProperty(elementObject, "finisher", "An element descriptor");

_disallowProperty(elementObject, "extras", "An element descriptor");

return element;
});
}

function _toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);

if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}

var key = _toPropertyKey(elementObject.key);

var placement = String(elementObject.placement);

if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}

var descriptor = elementObject.descriptor;

_disallowProperty(elementObject, "elements", "An element descriptor");

var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};

if (kind !== "field") {
_disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
_disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");

_disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");

_disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");

element.initializer = elementObject.initializer;
}

return element;
}

function _toElementFinisherExtras(elementObject) {
var element = _toElementDescriptor(elementObject);

var finisher = _optionalCallableProperty(elementObject, "finisher");

var extras = _toElementDescriptors(elementObject.extras);

return {
element: element,
finisher: finisher,
extras: extras
};
}

function _fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(_fromElementDescriptor)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
}

function _toClassDescriptor(obj) {
var kind = String(obj.kind);

if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}

_disallowProperty(obj, "key", "A class descriptor");

_disallowProperty(obj, "placement", "A class descriptor");

_disallowProperty(obj, "descriptor", "A class descriptor");

_disallowProperty(obj, "initializer", "A class descriptor");

_disallowProperty(obj, "extras", "A class descriptor");

var finisher = _optionalCallableProperty(obj, "finisher");

var elements = _toElementDescriptors(obj.elements);

return {
elements: elements,
finisher: finisher
};
}

function _disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}

function _optionalCallableProperty(obj, name) {
var value = obj[name];

if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}

return value;
}

function assertString(input) {
var isString = typeof input === 'string' || input instanceof String;

Expand Down Expand Up @@ -887,14 +702,14 @@ function isNumeric(str, options) {
return numeric.test(str);
}

var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
var _int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/;
var intLeadingZeroes = /^[-+]?[0-9]+$/;
function isInt(str, options) {
assertString(str);
options = options || {}; // Get the regex to use for testing, based on whether
// leading zeroes are allowed or not.

var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt
var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? _int : intLeadingZeroes; // Check min/max/lt/gt

var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min;
var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max;
Expand Down Expand Up @@ -966,14 +781,15 @@ function isSurrogatePair(str) {
function isFloat(str, options) {
assertString(str);
options = options || {};
var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));

var _float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$"));

if (str === '' || str === '.' || str === '-' || str === '+') {
return false;
}

var value = parseFloat(str.replace(',', '.'));
return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
return _float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt);
}
var locales$2 = Object.keys(decimal);

Expand Down Expand Up @@ -1219,8 +1035,8 @@ var validators = {
} // validate the control digit


var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) {
return charsValue[char];
var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (_char) {
return charsValue[_char];
});
return sanitized.endsWith(controlDigits[number % 23]);
}
Expand Down Expand Up @@ -1365,7 +1181,7 @@ function isISSN(str) {
var phones = {
'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,
'ar-EG': /^((\+?20)|0)?1[012]\d{8}$/,
'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/,
'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/,
'ar-JO': /^(\+?962|0)?7[789]\d{7}$/,
'ar-KW': /^(\+?965)[569]\d{7}$/,
Expand Down Expand Up @@ -1399,6 +1215,7 @@ var phones = {
'en-ZM': /^(\+?26)?09[567]\d{7}$/,
'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
Expand Down Expand Up @@ -1729,12 +1546,12 @@ function isMimeType(str) {
}

var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/;
var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
var _long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/;
var isLatLong = function (str) {
assertString(str);
if (!str.includes(',')) return false;
var pair = str.split(',');
return lat.test(pair[0]) && long.test(pair[1]);
return lat.test(pair[0]) && _long.test(pair[1]);
};

var threeDigit = /^\d{3}$/;
Expand All @@ -1761,6 +1578,7 @@ var patterns = {
GR: /^\d{3}\s?\d{2}$/,
HR: /^([1-5]\d{4}$)/,
HU: fourDigit,
ID: fiveDigit,
IL: fiveDigit,
IN: sixDigit,
IS: threeDigit,
Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit 330ad51

Please sign in to comment.