Skip to content

Commit

Permalink
test(isMobilePhone): add tests to ar-MA locale
Browse files Browse the repository at this point in the history
  • Loading branch information
artpumpkin committed Nov 16, 2020
1 parent 882d548 commit 4d4169d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
31 changes: 15 additions & 16 deletions validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function _unsupportedIterableToArray(o, minLen) {
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 === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

Expand Down Expand Up @@ -175,21 +175,10 @@ function assertString(input) {
var isString = typeof input === 'string' || input instanceof String;

if (!isString) {
var invalidType;
var invalidType = _typeof(input);

if (input === null) {
invalidType = 'null';
} else {
invalidType = _typeof(input);

if (invalidType === 'object' && input.constructor && input.constructor.hasOwnProperty('name')) {
invalidType = input.constructor.name;
} else {
invalidType = "a ".concat(invalidType);
}
}

throw new TypeError("Expected string but received ".concat(invalidType, "."));
if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name;
throw new TypeError("Expected a string but received a ".concat(invalidType));
}
}

Expand Down Expand Up @@ -428,7 +417,8 @@ function isByteLength(str, options) {
var default_fqdn_options = {
require_tld: true,
allow_underscores: false,
allow_trailing_dot: false
allow_trailing_dot: false,
allow_numeric_tld: false
};
function isFQDN(str, options) {
assertString(str);
Expand Down Expand Up @@ -463,6 +453,10 @@ function isFQDN(str, options) {
for (var part, _i = 0; _i < parts.length; _i++) {
part = parts[_i];

if (!options.allow_numeric_tld && _i === parts.length - 1 && /^\d+$/.test(part)) {
return false; // reject numeric TLDs
}

if (options.allow_underscores) {
part = part.replace(/_/g, '');
}
Expand Down Expand Up @@ -613,6 +607,7 @@ var default_email_options = {
require_display_name: false,
allow_utf8_local_part: true,
require_tld: true,
blacklisted_chars: '',
ignore_max_length: false
};
/* eslint-disable max-len */
Expand Down Expand Up @@ -774,6 +769,10 @@ function isEmail(str, options) {
}
}

if (options.blacklisted_chars) {
if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false;
}

return true;
}

Expand Down
Loading

0 comments on commit 4d4169d

Please sign in to comment.