diff --git a/lib/isFQDN.js b/lib/isFQDN.js index 67ca5d846..739569f44 100644 --- a/lib/isFQDN.js +++ b/lib/isFQDN.js @@ -35,6 +35,10 @@ function isFDQN(str, options) { if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; } + // disallow spaces + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + return false; + } } for (var part, i = 0; i < parts.length; i++) { part = parts[i]; diff --git a/src/lib/isFQDN.js b/src/lib/isFQDN.js index 673c80594..7d2933b56 100644 --- a/src/lib/isFQDN.js +++ b/src/lib/isFQDN.js @@ -21,6 +21,10 @@ export default function isFDQN(str, options) { if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; } + // disallow spaces + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + return false; + } } for (let part, i = 0; i < parts.length; i++) { part = parts[i]; diff --git a/test/validators.js b/test/validators.js index 171834910..35bc1f12a 100644 --- a/test/validators.js +++ b/test/validators.js @@ -71,6 +71,19 @@ describe('Validators', function () { 'gmailgmailgmailgmailgmail@gmail.com', `${repeat('a', 64)}@${repeat('a', 251)}.com`, `${repeat('a', 65)}@${repeat('a', 250)}.com`, + 'test1@invalid.co m', + 'test2@invalid.co m', + 'test3@invalid.co m', + 'test4@invalid.co m', + 'test5@invalid.co m', + 'test6@invalid.co m', + 'test7@invalid.co m', + 'test8@invalid.co m', + 'test9@invalid.co m', + 'test10@invalid.co m', + 'test11@invalid.co m', + 'test12@invalid.co m', + 'test13@invalid.co m', ], }); }); @@ -101,6 +114,7 @@ describe('Validators', function () { 'somename@gmail.com', 'hans.m端ller@test.com', 'z@co.c', + 'tüst@invalid.com', ], }); }); diff --git a/validator.js b/validator.js index b14413b59..f45e7589b 100644 --- a/validator.js +++ b/validator.js @@ -144,6 +144,10 @@ function isFDQN(str, options) { if (!parts.length || !/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { return false; } + // disallow spaces + if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(tld)) { + return false; + } } for (var part, i = 0; i < parts.length; i++) { part = parts[i]; diff --git a/validator.min.js b/validator.min.js index c78d3a760..91f1dfb4c 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 t(t){if(!("string"==typeof t||t instanceof String))throw new TypeError("This library (validator.js) validates strings only")}function e(e){return t(e),e=Date.parse(e),isNaN(e)?null:new Date(e)}function o(e){return t(e),parseFloat(e)}function r(t){return"object"===(void 0===t?"undefined":v(t))&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null===t||void 0===t||isNaN(t)&&!t.length)&&(t=""),String(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];for(var o in e)void 0===t[o]&&(t[o]=e[o]);return t}function n(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":v(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=encodeURI(e).split(/%..|./).length-1;return n>=r&&(void 0===i||n<=i)}function l(e,o){t(e),(o=i(o,F)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var r=e.split(".");if(o.require_tld){var n=r.pop();if(!r.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1}for(var l,a=0;a1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return u(e,4)||u(e,6);if("4"===o)return!!k.test(e)&&e.split(".").sort(function(t,e){return t-e})[3]<=255;if("6"===o){var r=e.split(":"),i=!1,n=u(r[r.length-1],4),l=n?7:8;if(r.length>l)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(r.shift(),r.shift(),i=!0):"::"===e.substr(e.length-2)&&(r.pop(),r.pop(),i=!0);for(var a=0;a0&&a=1:r.length===l}return!1}function s(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function d(t,e){for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return f(e,10)||f(e,13);var r=e.replace(/[\s-]+/g,""),i=0,n=void 0;if("10"===o){if(!et.test(r))return!1;for(n=0;n<9;n++)i+=(n+1)*r.charAt(n);if("X"===r.charAt(9)?i+=100:i+=10*r.charAt(9),i%11==0)return!!r}else if("13"===o){if(!ot.test(r))return!1;for(n=0;n<12;n++)i+=rt[n%2]*r.charAt(n);if(r.charAt(12)-(10-i%10)%10==0)return!!r}return!1}function p(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),o="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*"].join("|")+")?"+("(\\"+t.decimal_separator+"\\d{2})?");return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?o+="-?":t.negative_sign_before_digits&&(o="-?"+o)),t.allow_negative_sign_placeholder?o="( (?!\\-))?"+o:t.allow_space_after_symbol?o=" ?"+o:t.allow_space_after_digits&&(o+="( (?!$))?"),t.symbol_after_digits?o+=e:o=e+o,t.allow_negatives&&(t.parens_for_negatives?o="(\\("+o+"\\)|"+o+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(o="-?"+o)),new RegExp("^(?!-? )(?=.*\\d)"+o+"$")}function g(e,o){t(e);var r=o?new RegExp("^["+o+"]+","g"):/^\s+/g;return e.replace(r,"")}function h(e,o){t(e);for(var r=o?new RegExp("["+o+"]"):/\s/,i=e.length-1;i>=0&&r.test(e[i]);)i--;return i$/i,A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,w=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,y=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,b=/^([\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,k=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,S=/^[0-9A-F]{1,4}$/i,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},Z=/^\[([^\]]+)\](?::([0-9]+))?$/,E=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,O={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},R={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nl-NL":/^[0-9A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},C=["AU","GB","HK","IN","NZ","ZA","ZM"],I=0;I=0},matches:function(e,o,r){return t(e),"[object RegExp]"!==Object.prototype.toString.call(o)&&(o=new RegExp(o,r)),o.test(e)},isEmail:a,isURL:function(e,o){if(t(e),!e||e.length>=2083||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;o=i(o,D);var r=void 0,n=void 0,a=void 0,s=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=e.split("#"),e=p.shift(),p=e.split("?"),e=p.shift(),(p=e.split("://")).length>1){if(r=p.shift(),o.require_valid_protocol&&-1===o.protocols.indexOf(r))return!1}else{if(o.require_protocol)return!1;o.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(p[0]=e.substr(2))}if(e=p.join("://"),p=e.split("/"),""===(e=p.shift())&&!o.require_host)return!0;if((p=e.split("@")).length>1&&(n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,g=null;var h=(s=p.join("@")).match(Z);return h?(a="",g=h[1],f=h[2]||null):(a=(p=s.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(u(a)||l(a,o)||g&&u(g,6)||"localhost"===a)||(a=a||g,o.host_whitelist&&!d(a,o.host_whitelist)||o.host_blacklist&&d(a,o.host_blacklist)))},isMACAddress:function(e){return t(e),E.test(e)},isIP:u,isFQDN:l,isBoolean:function(e){return t(e),["true","false","1","0"].indexOf(e)>=0},isAlpha:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in O)return O[o].test(e);throw new Error("Invalid locale '"+o+"'")},isAlphanumeric:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in R)return R[o].test(e);throw new Error("Invalid locale '"+o+"'")},isNumeric:function(e){return t(e),P.test(e)},isLowercase:function(e){return t(e),e===e.toLowerCase()},isUppercase:function(e){return t(e),e===e.toUpperCase()},isAscii:function(e){return t(e),L.test(e)},isFullWidth:function(e){return t(e),N.test(e)},isHalfWidth:function(e){return t(e),B.test(e)},isVariableWidth:function(e){return t(e),N.test(e)&&B.test(e)},isMultibyte:function(e){return t(e),q.test(e)},isSurrogatePair:function(e){return t(e),T.test(e)},isInt:function(e,o){t(e);var r=(o=o||{}).hasOwnProperty("allow_leading_zeroes")&&!o.allow_leading_zeroes?H:K,i=!o.hasOwnProperty("min")||e>=o.min,n=!o.hasOwnProperty("max")||e<=o.max,l=!o.hasOwnProperty("lt")||eo.gt;return r.test(e)&&i&&n&&l&&a},isFloat:function(e,o){return t(e),o=o||{},""!==e&&"."!==e&&M.test(e)&&(!o.hasOwnProperty("min")||e>=o.min)&&(!o.hasOwnProperty("max")||e<=o.max)&&(!o.hasOwnProperty("lt")||eo.gt)},isDecimal:function(e){return t(e),""!==e&&W.test(e)},isHexadecimal:c,isDivisibleBy:function(e,r){return t(e),o(e)%parseInt(r,10)==0},isHexColor:function(e){return t(e),Y.test(e)},isISRC:function(e){return t(e),J.test(e)},isMD5:function(e){return t(e),Q.test(e)},isJSON:function(e){t(e);try{var o=JSON.parse(e);return!!o&&"object"===(void 0===o?"undefined":v(o))}catch(t){}return!1},isEmpty:function(e){return t(e),0===e.length},isLength:function(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":v(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-n.length;return l>=r&&(void 0===i||l<=i)},isByteLength:n,isUUID:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t(e);var r=X[o];return r&&r.test(e)},isMongoId:function(e){return t(e),c(e)&&24===e.length},isAfter:function(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n>i)},isBefore:function(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n=0}return"object"===(void 0===o?"undefined":v(o))?o.hasOwnProperty(e):!(!o||"function"!=typeof o.indexOf)&&o.indexOf(e)>=0},isCreditCard:function(e){t(e);var o=e.replace(/[^0-9]+/g,"");if(!V.test(o))return!1;for(var r=0,i=void 0,n=void 0,l=void 0,a=o.length-1;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),r+=l&&(n*=2)>=10?n%10+1:n,l=!l;return!(r%10!=0||!o)},isISIN:function(e){if(t(e),!tt.test(e))return!1;for(var o=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),r=0,i=void 0,n=void 0,l=!0,a=o.length-2;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),r+=l&&(n*=2)>=10?n+1:n,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-r)%10},isISBN:f,isISSN:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(e);var r=it;if(r=o.require_hyphen?r.replace("?",""):r,!(r=o.case_sensitive?new RegExp(r):new RegExp(r,"i")).test(e))return!1;var i=e.replace("-",""),n=8,l=0,a=!0,u=!1,s=void 0;try{for(var d,c=i[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){var f=d.value;l+=("X"===f.toUpperCase()?10:+f)*n,--n}}catch(t){u=!0,s=t}finally{try{!a&&c.return&&c.return()}finally{if(u)throw s}}return l%11==0},isMobilePhone:function(e,o){return t(e),o in nt?nt[o].test(e):"any"===o&&!!Object.values(nt).find(function(t){return t.test(e)})},isCurrency:function(e,o){return t(e),o=i(o,lt),p(o).test(e)},isISO8601:function(e){return t(e),at.test(e)},isBase64:function(e){t(e);var o=e.length;if(!o||o%4!=0||ut.test(e))return!1;var r=e.indexOf("=");return-1===r||r===o-1||r===o-2&&"="===e[o-1]},isDataURI:function(e){return t(e),st.test(e)},ltrim:g,rtrim:h,trim:function(t,e){return h(g(t,e),e)},escape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/`/g,"`")},stripLow:function(e,o){return t(e),m(e,o?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(e,o){return t(e),e.replace(new RegExp("[^"+o+"]+","g"),"")},blacklist:m,isWhitelisted:function(e,o){t(e);for(var r=e.length-1;r>=0;r--)if(-1===o.indexOf(e[r]))return!1;return!0},normalizeEmail:function(t,e){if(e=i(e,dt),!a(t))return!1;var o=t.split("@"),r=o.pop(),n=[o.join("@"),r];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(e.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),e.gmail_remove_dots&&(n[0]=n[0].replace(/\./g,"")),!n[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=e.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(~ct.indexOf(n[1])){if(e.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~ft.indexOf(n[1])){if(e.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~pt.indexOf(n[1])){if(e.yahoo_remove_subaddress){var l=n[0].split("-");n[0]=l.length>1?l.slice(0,-1).join("-"):l[0]}if(!n[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else e.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:r}}); \ No newline at end of file +!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 t(t){if(!("string"==typeof t||t instanceof String))throw new TypeError("This library (validator.js) validates strings only")}function e(e){return t(e),e=Date.parse(e),isNaN(e)?null:new Date(e)}function o(e){return t(e),parseFloat(e)}function r(t){return"object"===(void 0===t?"undefined":v(t))&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null===t||void 0===t||isNaN(t)&&!t.length)&&(t=""),String(t)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];for(var o in e)void 0===t[o]&&(t[o]=e[o]);return t}function n(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":v(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=encodeURI(e).split(/%..|./).length-1;return n>=r&&(void 0===i||n<=i)}function l(e,o){t(e),(o=i(o,F)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var r=e.split(".");if(o.require_tld){var n=r.pop();if(!r.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(n))return!1}for(var l,a=0;a1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return u(e,4)||u(e,6);if("4"===o)return!!k.test(e)&&e.split(".").sort(function(t,e){return t-e})[3]<=255;if("6"===o){var r=e.split(":"),i=!1,n=u(r[r.length-1],4),l=n?7:8;if(r.length>l)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(r.shift(),r.shift(),i=!0):"::"===e.substr(e.length-2)&&(r.pop(),r.pop(),i=!0);for(var a=0;a0&&a=1:r.length===l}return!1}function s(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function d(t,e){for(var o=0;o1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return f(e,10)||f(e,13);var r=e.replace(/[\s-]+/g,""),i=0,n=void 0;if("10"===o){if(!et.test(r))return!1;for(n=0;n<9;n++)i+=(n+1)*r.charAt(n);if("X"===r.charAt(9)?i+=100:i+=10*r.charAt(9),i%11==0)return!!r}else if("13"===o){if(!ot.test(r))return!1;for(n=0;n<12;n++)i+=rt[n%2]*r.charAt(n);if(r.charAt(12)-(10-i%10)%10==0)return!!r}return!1}function p(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),o="("+["0","[1-9]\\d*","[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*"].join("|")+")?"+("(\\"+t.decimal_separator+"\\d{2})?");return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?o+="-?":t.negative_sign_before_digits&&(o="-?"+o)),t.allow_negative_sign_placeholder?o="( (?!\\-))?"+o:t.allow_space_after_symbol?o=" ?"+o:t.allow_space_after_digits&&(o+="( (?!$))?"),t.symbol_after_digits?o+=e:o=e+o,t.allow_negatives&&(t.parens_for_negatives?o="(\\("+o+"\\)|"+o+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(o="-?"+o)),new RegExp("^(?!-? )(?=.*\\d)"+o+"$")}function g(e,o){t(e);var r=o?new RegExp("^["+o+"]+","g"):/^\s+/g;return e.replace(r,"")}function h(e,o){t(e);for(var r=o?new RegExp("["+o+"]"):/\s/,i=e.length-1;i>=0&&r.test(e[i]);)i--;return i$/i,A=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,w=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,y=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,b=/^([\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,k=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,D=/^[0-9A-F]{1,4}$/i,S={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},E=/^\[([^\]]+)\](?::([0-9]+))?$/,Z=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,O={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},R={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nl-NL":/^[0-9A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},C=["AU","GB","HK","IN","NZ","ZA","ZM"],I=0;I=0},matches:function(e,o,r){return t(e),"[object RegExp]"!==Object.prototype.toString.call(o)&&(o=new RegExp(o,r)),o.test(e)},isEmail:a,isURL:function(e,o){if(t(e),!e||e.length>=2083||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;o=i(o,S);var r=void 0,n=void 0,a=void 0,s=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=e.split("#"),e=p.shift(),p=e.split("?"),e=p.shift(),(p=e.split("://")).length>1){if(r=p.shift(),o.require_valid_protocol&&-1===o.protocols.indexOf(r))return!1}else{if(o.require_protocol)return!1;o.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(p[0]=e.substr(2))}if(e=p.join("://"),p=e.split("/"),""===(e=p.shift())&&!o.require_host)return!0;if((p=e.split("@")).length>1&&(n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1;f=null,g=null;var h=(s=p.join("@")).match(E);return h?(a="",g=h[1],f=h[2]||null):(a=(p=s.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(u(a)||l(a,o)||g&&u(g,6)||"localhost"===a)||(a=a||g,o.host_whitelist&&!d(a,o.host_whitelist)||o.host_blacklist&&d(a,o.host_blacklist)))},isMACAddress:function(e){return t(e),Z.test(e)},isIP:u,isFQDN:l,isBoolean:function(e){return t(e),["true","false","1","0"].indexOf(e)>=0},isAlpha:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in O)return O[o].test(e);throw new Error("Invalid locale '"+o+"'")},isAlphanumeric:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in R)return R[o].test(e);throw new Error("Invalid locale '"+o+"'")},isNumeric:function(e){return t(e),B.test(e)},isLowercase:function(e){return t(e),e===e.toLowerCase()},isUppercase:function(e){return t(e),e===e.toUpperCase()},isAscii:function(e){return t(e),P.test(e)},isFullWidth:function(e){return t(e),L.test(e)},isHalfWidth:function(e){return t(e),N.test(e)},isVariableWidth:function(e){return t(e),L.test(e)&&N.test(e)},isMultibyte:function(e){return t(e),q.test(e)},isSurrogatePair:function(e){return t(e),T.test(e)},isInt:function(e,o){t(e);var r=(o=o||{}).hasOwnProperty("allow_leading_zeroes")&&!o.allow_leading_zeroes?H:K,i=!o.hasOwnProperty("min")||e>=o.min,n=!o.hasOwnProperty("max")||e<=o.max,l=!o.hasOwnProperty("lt")||eo.gt;return r.test(e)&&i&&n&&l&&a},isFloat:function(e,o){return t(e),o=o||{},""!==e&&"."!==e&&M.test(e)&&(!o.hasOwnProperty("min")||e>=o.min)&&(!o.hasOwnProperty("max")||e<=o.max)&&(!o.hasOwnProperty("lt")||eo.gt)},isDecimal:function(e){return t(e),""!==e&&W.test(e)},isHexadecimal:c,isDivisibleBy:function(e,r){return t(e),o(e)%parseInt(r,10)==0},isHexColor:function(e){return t(e),Y.test(e)},isISRC:function(e){return t(e),J.test(e)},isMD5:function(e){return t(e),Q.test(e)},isJSON:function(e){t(e);try{var o=JSON.parse(e);return!!o&&"object"===(void 0===o?"undefined":v(o))}catch(t){}return!1},isEmpty:function(e){return t(e),0===e.length},isLength:function(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":v(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-n.length;return l>=r&&(void 0===i||l<=i)},isByteLength:n,isUUID:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t(e);var r=X[o];return r&&r.test(e)},isMongoId:function(e){return t(e),c(e)&&24===e.length},isAfter:function(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n>i)},isBefore:function(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n=0}return"object"===(void 0===o?"undefined":v(o))?o.hasOwnProperty(e):!(!o||"function"!=typeof o.indexOf)&&o.indexOf(e)>=0},isCreditCard:function(e){t(e);var o=e.replace(/[^0-9]+/g,"");if(!V.test(o))return!1;for(var r=0,i=void 0,n=void 0,l=void 0,a=o.length-1;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),r+=l&&(n*=2)>=10?n%10+1:n,l=!l;return!(r%10!=0||!o)},isISIN:function(e){if(t(e),!tt.test(e))return!1;for(var o=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),r=0,i=void 0,n=void 0,l=!0,a=o.length-2;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),r+=l&&(n*=2)>=10?n+1:n,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-r)%10},isISBN:f,isISSN:function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(e);var r=it;if(r=o.require_hyphen?r.replace("?",""):r,!(r=o.case_sensitive?new RegExp(r):new RegExp(r,"i")).test(e))return!1;var i=e.replace("-",""),n=8,l=0,a=!0,u=!1,s=void 0;try{for(var d,c=i[Symbol.iterator]();!(a=(d=c.next()).done);a=!0){var f=d.value;l+=("X"===f.toUpperCase()?10:+f)*n,--n}}catch(t){u=!0,s=t}finally{try{!a&&c.return&&c.return()}finally{if(u)throw s}}return l%11==0},isMobilePhone:function(e,o){return t(e),o in nt?nt[o].test(e):"any"===o&&!!Object.values(nt).find(function(t){return t.test(e)})},isCurrency:function(e,o){return t(e),o=i(o,lt),p(o).test(e)},isISO8601:function(e){return t(e),at.test(e)},isBase64:function(e){t(e);var o=e.length;if(!o||o%4!=0||ut.test(e))return!1;var r=e.indexOf("=");return-1===r||r===o-1||r===o-2&&"="===e[o-1]},isDataURI:function(e){return t(e),st.test(e)},ltrim:g,rtrim:h,trim:function(t,e){return h(g(t,e),e)},escape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(e){return t(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/`/g,"`")},stripLow:function(e,o){return t(e),m(e,o?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(e,o){return t(e),e.replace(new RegExp("[^"+o+"]+","g"),"")},blacklist:m,isWhitelisted:function(e,o){t(e);for(var r=e.length-1;r>=0;r--)if(-1===o.indexOf(e[r]))return!1;return!0},normalizeEmail:function(t,e){if(e=i(e,dt),!a(t))return!1;var o=t.split("@"),r=o.pop(),n=[o.join("@"),r];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(e.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),e.gmail_remove_dots&&(n[0]=n[0].replace(/\./g,"")),!n[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=e.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(~ct.indexOf(n[1])){if(e.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~ft.indexOf(n[1])){if(e.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~pt.indexOf(n[1])){if(e.yahoo_remove_subaddress){var l=n[0].split("-");n[0]=l.length>1?l.slice(0,-1).join("-"):l[0]}if(!n[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else e.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:r}}); \ No newline at end of file