From f0064e44ad06a81c19e33fa11a1dd9ef86a1a87d Mon Sep 17 00:00:00 2001 From: Michael Cerne Date: Wed, 16 Oct 2019 17:08:36 -0400 Subject: [PATCH] feat(isBtcAddress): add isBtcAddress validator --- README.md | 1 + index.js | 3 +++ lib/isBtcAddress.js | 21 +++++++++++++++++++++ src/index.js | 3 +++ src/lib/isBtcAddress.js | 9 +++++++++ test/validators.js | 16 ++++++++++++++++ validator.js | 7 +++++++ validator.min.js | 2 +- 8 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 lib/isBtcAddress.js create mode 100644 src/lib/isBtcAddress.js diff --git a/README.md b/README.md index f80aa2fe2..19fe6b996 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ Validator | Description **isByteLength(str [, options])** | check if the string's length (in UTF-8 bytes) falls in a range.

`options` is an object which defaults to `{min:0, max: undefined}`. **isCreditCard(str)** | check if the string is a credit card. **isCurrency(str [, options])** | check if the string is a valid currency amount.

`options` is an object which defaults to `{symbol: '$', require_symbol: false, allow_space_after_symbol: false, symbol_after_digits: false, allow_negatives: true, parens_for_negatives: false, negative_sign_before_digits: false, negative_sign_after_digits: false, allow_negative_sign_placeholder: false, thousands_separator: ',', decimal_separator: '.', allow_decimal: true, require_decimal: false, digits_after_decimal: [2], allow_space_after_digits: false}`.
**Note:** The array `digits_after_decimal` is filled with the exact number of digits allowed not a range, for example a range 1 to 3 will be given as [1, 2, 3]. +**isBtcAddress(str)** | check if the string is a valid BTC address. **isDataURI(str)** | check if the string is a [data uri format](https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs). **isDecimal(str [, options])** | check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc.

`options` is an object which defaults to `{force_decimal: false, decimal_digits: '1,', locale: 'en-US'}`

`locale` determine the decimal separator and is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'hu-HU', 'it-IT', 'ku-IQ', nb-NO', 'nl-NL', 'nn-NO', 'pl-PL', 'pt-BR', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS', 'sr-RS@latin', 'sv-SE', 'tr-TR', 'uk-UA']`.
**Note:** `decimal_digits` is given as a range like '1,3', a specific value like '3' or min like '1,'. **isDivisibleBy(str, number)** | check if the string is a number that's divisible by another. diff --git a/index.js b/index.js index 13e7907ef..55ff3e358 100644 --- a/index.js +++ b/index.js @@ -111,6 +111,8 @@ var _isMobilePhone = _interopRequireWildcard(require("./lib/isMobilePhone")); var _isCurrency = _interopRequireDefault(require("./lib/isCurrency")); +var _isBtcAddress = _interopRequireDefault(require("./lib/isBtcAddress")); + var _isISO = _interopRequireDefault(require("./lib/isISO8601")); var _isRFC = _interopRequireDefault(require("./lib/isRFC3339")); @@ -221,6 +223,7 @@ var validator = { isPostalCode: _isPostalCode.default, isPostalCodeLocales: _isPostalCode.locales, isCurrency: _isCurrency.default, + isBtcAddress: _isBtcAddress.default, isISO8601: _isISO.default, isRFC3339: _isRFC.default, isISO31661Alpha2: _isISO31661Alpha.default, diff --git a/lib/isBtcAddress.js b/lib/isBtcAddress.js new file mode 100644 index 000000000..f61460d5f --- /dev/null +++ b/lib/isBtcAddress.js @@ -0,0 +1,21 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = isBtcAddress; + +var _assertString = _interopRequireDefault(require("./util/assertString")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// supports Bech32 addresses +var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; + +function isBtcAddress(str) { + (0, _assertString.default)(str); + return btc.test(str); +} + +module.exports = exports.default; +module.exports.default = exports.default; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 04f60149d..5e1605de8 100644 --- a/src/index.js +++ b/src/index.js @@ -71,6 +71,8 @@ import isMobilePhone, { locales as isMobilePhoneLocales } from './lib/isMobilePh import isCurrency from './lib/isCurrency'; +import isBtcAddress from './lib/isBtcAddress'; + import isISO8601 from './lib/isISO8601'; import isRFC3339 from './lib/isRFC3339'; import isISO31661Alpha2 from './lib/isISO31661Alpha2'; @@ -164,6 +166,7 @@ const validator = { isPostalCode, isPostalCodeLocales, isCurrency, + isBtcAddress, isISO8601, isRFC3339, isISO31661Alpha2, diff --git a/src/lib/isBtcAddress.js b/src/lib/isBtcAddress.js new file mode 100644 index 000000000..0c50142a2 --- /dev/null +++ b/src/lib/isBtcAddress.js @@ -0,0 +1,9 @@ +import assertString from './util/assertString'; + +// supports Bech32 addresses +const btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; + +export default function isBtcAddress(str) { + assertString(str); + return btc.test(str); +} diff --git a/test/validators.js b/test/validators.js index aee86d7f1..e8ddf2258 100644 --- a/test/validators.js +++ b/test/validators.js @@ -6311,6 +6311,22 @@ describe('Validators', () => { }); }); + it('should validate Bitcoin addresses', () => { + test({ + validator: 'isBtcAddress', + valid: [ + '1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL', + '3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy', + 'bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq', + ], + invalid: [ + '4J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy', + '0x56F0B8A998425c53c75C4A303D4eF987533c5597', + 'pp8skudq3x5hzw8ew7vzsw8tn4k8wxsqsv0lt0mf3g', + ], + }); + }); + it('should validate booleans', () => { test({ validator: 'isBoolean', diff --git a/validator.js b/validator.js index defa7d437..a4fe25d5f 100644 --- a/validator.js +++ b/validator.js @@ -1555,6 +1555,12 @@ function isCurrency(str, options) { return currencyRegex(options).test(str); } +var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; +function isBtcAddress(str) { + assertString(str); + return btc.test(str); +} + /* eslint-disable max-len */ // from http://goo.gl/0ejHHW @@ -2097,6 +2103,7 @@ var validator = { isPostalCode: isPostalCode, isPostalCodeLocales: locales$4, isCurrency: isCurrency, + isBtcAddress: isBtcAddress, isISO8601: isISO8601, isRFC3339: isRFC3339, isISO31661Alpha2: isISO31661Alpha2, diff --git a/validator.min.js b/validator.min.js index a0eeb6c2c..aeab8e1ec 100644 --- a/validator.min.js +++ b/validator.min.js @@ -20,4 +20,4 @@ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.validator=e()}(this,function(){"use strict";function a(t){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function $(t){var e;if(!("string"==typeof t||t instanceof String))throw e=null===t?"null":"object"===(e=a(t))&&t.constructor&&t.constructor.hasOwnProperty("name")?t.constructor.name:"a ".concat(e),new TypeError("Expected string but received ".concat(e,"."))}function o(t){return $(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function r(t){return $(t),parseFloat(t)}function i(t){return"object"===a(t)&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null==t||isNaN(t)&&!t.length)&&(t=""),String(t)}function m(t,e){var r=0i)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(r.shift(),r.shift(),n=!0):"::"===t.substr(t.length-2)&&(r.pop(),r.pop(),n=!0);for(var a=0;a$/i,E=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^[a-z\d]+$/,M=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,w=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,N=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;var d={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},f=/^\[([^\]]+)\](?::([0-9]+))?$/;function p(t,e){for(var r=0;r=e.min,o=!e.hasOwnProperty("max")||t<=e.max,i=!e.hasOwnProperty("lt")||te.gt;return r.test(t)&&n&&o&&i&&a}var V=/^[\x00-\x7F]+$/;var j=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var J=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var q=/[^\x00-\x7F]/;var Q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/;function X(t,e){return t.some(function(t){return e===t})}var tt=Object.keys(T);var et={force_decimal:!1,decimal_digits:"1,",locale:"en-US"},rt=["","-","+"];var nt=/^[0-9A-F]+$/i;function ot(t){return $(t),nt.test(t)}var it=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;var at=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;var st=/^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;var lt=/^[a-f0-9]{32}$/;var ut={md5:32,md4:32,sha1:40,sha256:64,sha384:96,sha512:128,ripemd128:32,ripemd160:40,tiger128:32,tiger160:40,tiger192:48,crc32:8,crc32b:8};var ct=/^([A-Za-z0-9\-_~+\/]+[=]{0,2})\.([A-Za-z0-9\-_~+\/]+[=]{0,2})(?:\.([A-Za-z0-9\-_~+\/]+[=]{0,2}))?$/;var dt={ignore_whitespace:!1};var ft={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};var pt=/^(?: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 ht={ES:function(t){$(t);var e={X:0,Y:1,Z:2},r=t.trim().toUpperCase();if(!/^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/.test(r))return!1;var n=r.slice(0,-1).replace(/[X,Y,Z]/g,function(t){return e[t]});return r.endsWith(["T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E"][n%23])},"he-IL":function(t){var e=t.trim();if(!/^\d{9}$/.test(e))return!1;for(var r,n=e,o=0,i=0;i]/.test(r)){if(!e)return!1;if(!(r.split('"').length===r.split('\\"').length))return!1}return!0}(n))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&254]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;var r,n,o,i,a,s,l,u;if(e=m(e,d),1<(l=(t=(l=(t=(l=t.split("#")).shift()).split("?")).shift()).split("://")).length){if(r=l.shift().toLowerCase(),e.require_valid_protocol&&-1===e.protocols.indexOf(r))return!1}else{if(e.require_protocol)return!1;if("//"===t.substr(0,2)){if(!e.allow_protocol_relative_urls)return!1;l[0]=t.substr(2)}}if(""===(t=l.join("://")))return!1;if(""===(t=(l=t.split("/")).shift())&&!e.require_host)return!0;if(1<(l=t.split("@")).length){if(e.disallow_auth)return!1;if(0<=(n=l.shift()).indexOf(":")&&2=e.min)&&(!e.hasOwnProperty("max")||n<=e.max)&&(!e.hasOwnProperty("lt")||ne.gt)},isFloatLocales:tt,isDecimal:function(t,e){if($(t),(e=m(e,et)).locale in T)return!X(rt,t.replace(/ /g,""))&&function(t){return new RegExp("^[-+]?([0-9]+)?(\\".concat(T[t.locale],"[0-9]{").concat(t.decimal_digits,"})").concat(t.force_decimal?"":"?","$"))}(e).test(t);throw new Error("Invalid locale '".concat(e.locale,"'"))},isHexadecimal:ot,isDivisibleBy:function(t,e){return $(t),r(t)%parseInt(e,10)==0},isHexColor:function(t){return $(t),it.test(t)},isISRC:function(t){return $(t),at.test(t)},isMD5:function(t){return $(t),lt.test(t)},isHash:function(t,e){return $(t),new RegExp("^[a-fA-F0-9]{".concat(ut[e],"}$")).test(t)},isJWT:function(t){return $(t),ct.test(t)},isJSON:function(t){$(t);try{var e=JSON.parse(t);return!!e&&"object"===a(e)}catch(t){}return!1},isEmpty:function(t,e){return $(t),0===((e=m(e,dt)).ignore_whitespace?t.trim().length:t.length)},isLength:function(t,e){var r,n;$(t),n="object"===a(e)?(r=e.min||0,e.max):(r=e||0,arguments[2]);var o=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],i=t.length-o.length;return r<=i&&(void 0===n||i<=n)},isByteLength:v,isUUID:function(t){var e=1/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return $(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,e){return $(t),qt(t,e?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,e){return $(t),t.replace(new RegExp("[^".concat(e,"]+"),"g"),"")},blacklist:qt,isWhitelisted:function(t,e){$(t);for(var r=t.length-1;0<=r;r--)if(-1===e.indexOf(t[r]))return!1;return!0},normalizeEmail:function(t,e){e=m(e,Qt);var r=t.split("@"),n=r.pop(),o=[r.join("@"),n];if(o[1]=o[1].toLowerCase(),"gmail.com"===o[1]||"googlemail.com"===o[1]){if(e.gmail_remove_subaddress&&(o[0]=o[0].split("+")[0]),e.gmail_remove_dots&&(o[0]=o[0].replace(/\.+/g,ne)),!o[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(o[0]=o[0].toLowerCase()),o[1]=e.gmail_convert_googlemaildotcom?"gmail.com":o[1]}else if(0<=Xt.indexOf(o[1])){if(e.icloud_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=te.indexOf(o[1])){if(e.outlookdotcom_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=ee.indexOf(o[1])){if(e.yahoo_remove_subaddress){var i=o[0].split("-");o[0]=1i)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(r.shift(),r.shift(),n=!0):"::"===t.substr(t.length-2)&&(r.pop(),r.pop(),n=!0);for(var a=0;a$/i,E=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^[a-z\d]+$/,M=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,w=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,N=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;var d={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},f=/^\[([^\]]+)\](?::([0-9]+))?$/;function p(t,e){for(var r=0;r=e.min,o=!e.hasOwnProperty("max")||t<=e.max,i=!e.hasOwnProperty("lt")||te.gt;return r.test(t)&&n&&o&&i&&a}var V=/^[\x00-\x7F]+$/;var j=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var J=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var q=/[^\x00-\x7F]/;var Q=/[\uD800-\uDBFF][\uDC00-\uDFFF]/;function X(t,e){return t.some(function(t){return e===t})}var tt=Object.keys(Z);var et={force_decimal:!1,decimal_digits:"1,",locale:"en-US"},rt=["","-","+"];var nt=/^(0x|0h)?[0-9A-F]+$/i;function ot(t){return $(t),nt.test(t)}var it=/^(0o)?[0-7]+$/i;var at=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;var st=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;var lt=/^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/;var ut=/^[a-f0-9]{32}$/;var ct={md5:32,md4:32,sha1:40,sha256:64,sha384:96,sha512:128,ripemd128:32,ripemd160:40,tiger128:32,tiger160:40,tiger192:48,crc32:8,crc32b:8};var dt=/^([A-Za-z0-9\-_~+\/]+[=]{0,2})\.([A-Za-z0-9\-_~+\/]+[=]{0,2})(?:\.([A-Za-z0-9\-_~+\/]+[=]{0,2}))?$/;var ft={ignore_whitespace:!1};var pt={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};var ht=/^(?: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 At={ES:function(t){$(t);var e={X:0,Y:1,Z:2},r=t.trim().toUpperCase();if(!/^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/.test(r))return!1;var n=r.slice(0,-1).replace(/[X,Y,Z]/g,function(t){return e[t]});return r.endsWith(["T","R","W","A","G","M","Y","F","P","D","X","B","N","J","Z","S","Q","V","H","L","C","K","E"][n%23])},"he-IL":function(t){var e=t.trim();if(!/^\d{9}$/.test(e))return!1;for(var r,n=e,o=0,i=0;i]/.test(r)){if(!e)return!1;if(!(r.split('"').length===r.split('\\"').length))return!1}return!0}(n))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&254]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;var r,n,o,i,a,s,l,u;if(e=m(e,d),1<(l=(t=(l=(t=(l=t.split("#")).shift()).split("?")).shift()).split("://")).length){if(r=l.shift().toLowerCase(),e.require_valid_protocol&&-1===e.protocols.indexOf(r))return!1}else{if(e.require_protocol)return!1;if("//"===t.substr(0,2)){if(!e.allow_protocol_relative_urls)return!1;l[0]=t.substr(2)}}if(""===(t=l.join("://")))return!1;if(""===(t=(l=t.split("/")).shift())&&!e.require_host)return!0;if(1<(l=t.split("@")).length){if(e.disallow_auth)return!1;if(0<=(n=l.shift()).indexOf(":")&&2=e.min)&&(!e.hasOwnProperty("max")||n<=e.max)&&(!e.hasOwnProperty("lt")||ne.gt)},isFloatLocales:tt,isDecimal:function(t,e){if($(t),(e=m(e,et)).locale in Z)return!X(rt,t.replace(/ /g,""))&&function(t){return new RegExp("^[-+]?([0-9]+)?(\\".concat(Z[t.locale],"[0-9]{").concat(t.decimal_digits,"})").concat(t.force_decimal?"":"?","$"))}(e).test(t);throw new Error("Invalid locale '".concat(e.locale,"'"))},isHexadecimal:ot,isOctal:function(t){return $(t),it.test(t)},isDivisibleBy:function(t,e){return $(t),r(t)%parseInt(e,10)==0},isHexColor:function(t){return $(t),at.test(t)},isISRC:function(t){return $(t),st.test(t)},isMD5:function(t){return $(t),ut.test(t)},isHash:function(t,e){return $(t),new RegExp("^[a-fA-F0-9]{".concat(ct[e],"}$")).test(t)},isJWT:function(t){return $(t),dt.test(t)},isJSON:function(t){$(t);try{var e=JSON.parse(t);return!!e&&"object"===a(e)}catch(t){}return!1},isEmpty:function(t,e){return $(t),0===((e=m(e,ft)).ignore_whitespace?t.trim().length:t.length)},isLength:function(t,e){var r,n;$(t),n="object"===a(e)?(r=e.min||0,e.max):(r=e||0,arguments[2]);var o=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],i=t.length-o.length;return r<=i&&(void 0===n||i<=n)},isByteLength:v,isUUID:function(t){var e=1/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return $(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,e){return $(t),Xt(t,e?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,e){return $(t),t.replace(new RegExp("[^".concat(e,"]+"),"g"),"")},blacklist:Xt,isWhitelisted:function(t,e){$(t);for(var r=t.length-1;0<=r;r--)if(-1===e.indexOf(t[r]))return!1;return!0},normalizeEmail:function(t,e){e=m(e,te);var r=t.split("@"),n=r.pop(),o=[r.join("@"),n];if(o[1]=o[1].toLowerCase(),"gmail.com"===o[1]||"googlemail.com"===o[1]){if(e.gmail_remove_subaddress&&(o[0]=o[0].split("+")[0]),e.gmail_remove_dots&&(o[0]=o[0].replace(/\.+/g,ie)),!o[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(o[0]=o[0].toLowerCase()),o[1]=e.gmail_convert_googlemaildotcom?"gmail.com":o[1]}else if(0<=ee.indexOf(o[1])){if(e.icloud_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=re.indexOf(o[1])){if(e.outlookdotcom_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=ne.indexOf(o[1])){if(e.yahoo_remove_subaddress){var i=o[0].split("-");o[0]=1