diff --git a/CHANGELOG.md b/CHANGELOG.md index 7989ac263..e3696f7bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ - New locales ([#585](https://github.com/chriso/validator.js/pull/585)) +- Added support for greater or less than in `isFloat()` + ([#544](https://github.com/chriso/validator.js/issues/544)) #### 6.0.0 diff --git a/README.md b/README.md index 86c51cf1e..2cec6f8f8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Passing anything other than a string is an error. - **isEmail(str [, options])** - check if the string is an email. `options` is an object which defaults to `{ allow_display_name: false, allow_utf8_local_part: true, require_tld: true }`. If `allow_display_name` is set to true, the validator will also match `Display Name `. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. - **isEmpty(str)** - check if the string has a length of zero. - **isFQDN(str [, options])** - check if the string is a fully qualified domain name (e.g. domain.com). `options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false }`. -- **isFloat(str [, options])** - check if the string is a float. `options` is an object which can contain the keys `min` and/or `max` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`). +- **isFloat(str [, options])** - check if the string is a float. `options` is an object which can contain the keys `min`, `max`, `gt`, and/or `lt` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`). `min` and `max` are equivalent to 'greater or equal' and 'less or equal', respectively while `gt` and `lt` are their strict counterparts. - **isFullWidth(str)** - check if the string contains any full-width chars. - **isHalfWidth(str)** - check if the string contains any half-width chars. - **isHexColor(str)** - check if the string is a hexadecimal color. diff --git a/lib/isFloat.js b/lib/isFloat.js index a19bcaa2e..15c759b16 100644 --- a/lib/isFloat.js +++ b/lib/isFloat.js @@ -19,6 +19,6 @@ function isFloat(str, options) { if (str === '' || str === '.') { return false; } - return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max); + return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max) && (!options.hasOwnProperty('lt') || str < options.lt) && (!options.hasOwnProperty('gt') || str > options.gt); } module.exports = exports['default']; \ No newline at end of file diff --git a/src/lib/isFloat.js b/src/lib/isFloat.js index 209f8d29a..7e1741061 100644 --- a/src/lib/isFloat.js +++ b/src/lib/isFloat.js @@ -10,5 +10,7 @@ export default function isFloat(str, options) { } return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && - (!options.hasOwnProperty('max') || str <= options.max); + (!options.hasOwnProperty('max') || str <= options.max) && + (!options.hasOwnProperty('lt') || str < options.lt) && + (!options.hasOwnProperty('gt') || str > options.gt); } diff --git a/test/validators.js b/test/validators.js index 319088bf7..5a90da3d1 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1252,6 +1252,46 @@ describe('Validators', function () { '5', ], }); + test({ + validator: 'isFloat', + args: [{ + gt: -5.5, + lt: 10, + }], + valid: [ + '9.9', + '1.0', + '0', + '-1', + '7', + '-5.4', + ], + invalid: [ + '10', + '-5.5', + 'a', + '-20.3', + '20e3', + '10.00001', + ], + }); + test({ + validator: 'isFloat', + args: [{ + min: -5.5, + max: 10, + gt: -5.5, + lt: 10, + }], + valid: [ + '9.99999', + '-5.499999', + ], + invalid: [ + '10', + '-5.5', + ], + }); }); it('should validate hexadecimal strings', function () { diff --git a/validator.js b/validator.js index e25aa567a..8ba47e800 100644 --- a/validator.js +++ b/validator.js @@ -696,7 +696,7 @@ if (str === '' || str === '.') { return false; } - return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max); + return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max) && (!options.hasOwnProperty('lt') || str < options.lt) && (!options.hasOwnProperty('gt') || str > options.gt); } var decimal = /^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/; diff --git a/validator.min.js b/validator.min.js index d024ff331..feedd63ce 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)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(e,o){return t(e),parseInt(e,o||10)}function n(e,o){return t(e),o?"1"===e||"true"===e:"0"!==e&&"false"!==e&&""!==e}function i(e,o){return t(e),e===o}function l(t){return"object"===("undefined"==typeof t?"undefined":pt(t))&&null!==t?t="function"==typeof t.toString?t.toString():"[object Object]":(null===t||"undefined"==typeof t||isNaN(t)&&!t.length)&&(t=""),String(t)}function a(e,o){return t(e),e.indexOf(l(o))>=0}function u(e,o,r){return t(e),"[object RegExp]"!==Object.prototype.toString.call(o)&&(o=new RegExp(o,r)),o.test(e)}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];for(var o in e)"undefined"==typeof t[o]&&(t[o]=e[o]);return t}function c(e,o){t(e);var r=void 0,n=void 0;"object"===("undefined"==typeof o?"undefined":pt(o))?(r=o.min||0,n=o.max):(r=arguments[1],n=arguments[2]);var i=encodeURI(e).split(/%..|./).length-1;return i>=r&&("undefined"==typeof n||i<=n)}function f(e,o){t(e),o=s(o,ht),o.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 i,l=0;l1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),o=String(o),!o)return p(e,4)||p(e,6);if("4"===o){if(!xt.test(e))return!1;var r=e.split(".").sort(function(t,e){return t-e});return r[3]<=255}if("6"===o){var n=e.split(":"),i=!1,l=p(n[n.length-1],4),a=l?7:8;if(n.length>a)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(n.shift(),n.shift(),i=!0):"::"===e.substr(e.length-2)&&(n.pop(),n.pop(),i=!0);for(var u=0;u0&&u=1:n.length===a}return!1}function h(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function g(t,e){for(var o=0;o=2083||/\s/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;o=s(o,wt);var r=void 0,n=void 0,i=void 0,l=void 0,a=void 0,u=void 0,c=void 0,d=void 0;if(c=e.split("#"),e=c.shift(),c=e.split("?"),e=c.shift(),c=e.split("://"),c.length>1){if(r=c.shift(),o.require_valid_protocol&&o.protocols.indexOf(r)===-1)return!1}else{if(o.require_protocol)return!1;o.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(c[0]=e.substr(2))}if(e=c.join("://"),c=e.split("/"),e=c.shift(),""===e&&!o.require_host)return!0;if(c=e.split("@"),c.length>1&&(n=c.shift(),n.indexOf(":")>=0&&n.split(":").length>2))return!1;l=c.join("@"),u=d=null;var h=l.match(yt);return h?(i="",d=h[1],u=h[2]||null):(c=l.split(":"),i=c.shift(),c.length&&(u=c.join(":"))),!(null!==u&&(a=parseInt(u,10),!/^[0-9]+$/.test(u)||a<=0||a>65535))&&(!!(p(i)||f(i,o)||d&&p(d,6)||"localhost"===i)&&(i=i||d,!(o.host_whitelist&&!g(i,o.host_whitelist))&&(!o.host_blacklist||!g(i,o.host_blacklist))))}function v(e){return t(e),bt.test(e)}function _(e){return t(e),["true","false","1","0"].indexOf(e)>=0}function F(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in kt)return kt[o].test(e);throw new Error("Invalid locale '"+o+"'")}function $(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in Dt)return Dt[o].test(e);throw new Error("Invalid locale '"+o+"'")}function x(e){return t(e),Ct.test(e)}function A(e){return t(e),e===e.toLowerCase()}function w(e){return t(e),e===e.toUpperCase()}function y(e){return t(e),Rt.test(e)}function b(e){return t(e),jt.test(e)}function k(e){return t(e),zt.test(e)}function D(e){return t(e),jt.test(e)&&zt.test(e)}function S(e){return t(e),Ut.test(e)}function E(e){return t(e),Nt.test(e)}function Z(e,o){t(e),o=o||{};var r=o.hasOwnProperty("allow_leading_zeroes")&&!o.allow_leading_zeroes?Bt:Lt,n=!o.hasOwnProperty("min")||e>=o.min,i=!o.hasOwnProperty("max")||e<=o.max;return r.test(e)&&n&&i}function I(e,o){return t(e),o=o||{},""!==e&&"."!==e&&(Pt.test(e)&&(!o.hasOwnProperty("min")||e>=o.min)&&(!o.hasOwnProperty("max")||e<=o.max))}function O(e){return t(e),""!==e&&qt.test(e)}function C(e){return t(e),Tt.test(e)}function R(e,r){return t(e),o(e)%parseInt(r,10)===0}function j(e){return t(e),Mt.test(e)}function z(e){return t(e),Ht.test(e)}function U(e){t(e);try{var o=JSON.parse(e);return!!o&&"object"===("undefined"==typeof o?"undefined":pt(o))}catch(t){}return!1}function N(e){return t(e),0===e.length}function B(e,o){t(e);var r=void 0,n=void 0;"object"===("undefined"==typeof o?"undefined":pt(o))?(r=o.min||0,n=o.max):(r=arguments[1],n=arguments[2]);var i=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-i.length;return l>=r&&("undefined"==typeof n||l<=n)}function L(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t(e);var r=Wt[o];return r&&r.test(e)}function P(e){return t(e),C(e)&&24===e.length}function q(e){return t(e),Yt.test(e)}function T(t){var e=t.match(Yt),o=void 0,r=void 0,n=void 0,i=void 0;if(e){if(o=e[21],!o)return e[12]?null:0;if("z"===o||"Z"===o)return 0;r=e[22],o.indexOf(":")!==-1?(n=parseInt(e[23],10),i=parseInt(e[24],10)):(n=0,i=parseInt(e[23],10))}else{if(t=t.toLowerCase(),o=t.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!o)return t.indexOf("gmt")!==-1?0:null;r=o[1];var l=o[2];3===l.length&&(l="0"+l),l.length<=2?(n=0,i=parseInt(l,10)):(n=parseInt(l.slice(0,2),10),i=parseInt(l.slice(2,4),10))}return(60*n+i)*("-"===r?1:-1)}function M(e){t(e);var o=new Date(Date.parse(e));if(isNaN(o))return!1;var r=T(e);if(null!==r){var n=o.getTimezoneOffset()-r;o=new Date(o.getTime()+6e4*n)}var i=String(o.getDate()),l=void 0,a=void 0,u=void 0;return!(a=e.match(/(^|[^:\d])[23]\d([^T:\d]|$)/g))||(l=a.map(function(t){return t.match(/\d+/g)[0]}).join("/"),u=String(o.getFullYear()).slice(-2),l===i||l===u||(l===""+i/u||l===""+u/i))}function H(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var n=e(r),i=e(o);return!!(i&&n&&i>n)}function W(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var n=e(r),i=e(o);return!!(i&&n&&i=0}return"object"===("undefined"==typeof o?"undefined":pt(o))?o.hasOwnProperty(e):!(!o||"function"!=typeof o.indexOf)&&o.indexOf(e)>=0}function G(e){t(e);var o=e.replace(/[^0-9]+/g,"");if(!Gt.test(o))return!1;for(var r=0,n=void 0,i=void 0,l=void 0,a=o.length-1;a>=0;a--)n=o.substring(a,a+1),i=parseInt(n,10),l?(i*=2,r+=i>=10?i%10+1:i):r+=i,l=!l;return!(r%10!==0||!o)}function J(e){if(t(e),!Jt.test(e))return!1;for(var o=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),r=0,n=void 0,i=void 0,l=!0,a=o.length-2;a>=0;a--)n=o.substring(a,a+1),i=parseInt(n,10),l?(i*=2,r+=i>=10?i+1:i):r+=i,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-r)%10}function K(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),o=String(o),!o)return K(e,10)||K(e,13);var r=e.replace(/[\s-]+/g,""),n=0,i=void 0;if("10"===o){if(!Kt.test(r))return!1;for(i=0;i<9;i++)n+=(i+1)*r.charAt(i);if(n+="X"===r.charAt(9)?100:10*r.charAt(9),n%11===0)return!!r}else if("13"===o){if(!Qt.test(r))return!1;for(i=0;i<12;i++)n+=Vt[i%2]*r.charAt(i);if(r.charAt(12)-(10-n%10)%10===0)return!!r}return!1}function Q(e,o){return t(e),o in Xt&&Xt[o].test(e)}function V(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),o="-?",r="[1-9]\\d*",n="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",i=["0",r,n],l="("+i.join("|")+")?",a="(\\"+t.decimal_separator+"\\d{2})?",u=l+a;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?u+=o:t.negative_sign_before_digits&&(u=o+u)),t.allow_negative_sign_placeholder?u="( (?!\\-))?"+u:t.allow_space_after_symbol?u=" ?"+u:t.allow_space_after_digits&&(u+="( (?!$))?"),t.symbol_after_digits?u+=e:u=e+u,t.allow_negatives&&(t.parens_for_negatives?u="(\\("+u+"\\)|"+u+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(u=o+u)),new RegExp("^(?!-? )(?=.*\\d)"+u+"$")}function X(e,o){return t(e),o=s(o,te),V(o).test(e)}function tt(e){t(e);var o=e.length;if(!o||o%4!==0||ee.test(e))return!1;var r=e.indexOf("=");return r===-1||r===o-1||r===o-2&&"="===e[o-1]}function et(e){return t(e),oe.test(e)}function ot(e,o){t(e);var r=o?new RegExp("^["+o+"]+","g"):/^\s+/g;return e.replace(r,"")}function rt(e,o){t(e);for(var r=o?new RegExp("["+o+"]"):/\s/,n=e.length-1;n>=0&&r.test(e[n]);)n--;return n/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")}function lt(e){return t(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/`/g,"`")}function at(e,o){return t(e),e.replace(new RegExp("["+o+"]+","g"),"")}function ut(e,o){t(e);var r=o?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return at(e,r)}function st(e,o){return t(e),e.replace(new RegExp("[^"+o+"]+","g"),"")}function ct(e,o){t(e);for(var r=e.length-1;r>=0;r--)if(o.indexOf(e[r])===-1)return!1;return!0}function ft(t,e){if(e=s(e,re),!d(t))return!1;var o=t.split("@",2);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,"")),!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(~ne.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(~ie.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(~le.indexOf(o[1])){if(e.yahoo_remove_subaddress){var r=o[0].split("-");o[0]=r.length>1?r.slice(0,-1).join("-"):r[0]}if(!o[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(o[0]=o[0].toLowerCase())}else e.all_lowercase&&(o[0]=o[0].toLowerCase());return o.join("@")}for(var dt,pt="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},ht=(function(){function t(t){this.value=t}function e(e){function o(t,e){return new Promise(function(o,n){var a={key:t,arg:e,resolve:o,reject:n,next:null};l?l=l.next=a:(i=l=a,r(t,e))})}function r(o,i){try{var l=e[o](i),a=l.value;a instanceof t?Promise.resolve(a.value).then(function(t){r("next",t)},function(t){r("throw",t)}):n(l.done?"return":"normal",l.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}i=i.next,i?r(i.key,i.arg):l=null}var i,l;this._invoke=o,"function"!=typeof e.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new e(t.apply(this,arguments))}},await:function(e){return new t(e)}}}(),{require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1}),gt={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},mt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,vt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,_t=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,Ft=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,$t=/^([\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,xt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,At=/^[0-9A-F]{1,4}$/i,wt={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},yt=/^\[([^\]]+)\](?::([0-9]+))?$/,bt=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,kt={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[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:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Dt={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[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ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},St=["AU","GB","HK","IN","NZ","ZA","ZM"],Et=0;Et=0}function u(e,o,r){return t(e),"[object RegExp]"!==Object.prototype.toString.call(o)&&(o=new RegExp(o,r)),o.test(e)}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];for(var o in e)"undefined"==typeof t[o]&&(t[o]=e[o]);return t}function c(e,o){t(e);var r=void 0,n=void 0;"object"===("undefined"==typeof o?"undefined":pt(o))?(r=o.min||0,n=o.max):(r=arguments[1],n=arguments[2]);var i=encodeURI(e).split(/%..|./).length-1;return i>=r&&("undefined"==typeof n||i<=n)}function f(e,o){t(e),o=s(o,ht),o.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 i,l=0;l1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),o=String(o),!o)return p(e,4)||p(e,6);if("4"===o){if(!xt.test(e))return!1;var r=e.split(".").sort(function(t,e){return t-e});return r[3]<=255}if("6"===o){var n=e.split(":"),i=!1,l=p(n[n.length-1],4),a=l?7:8;if(n.length>a)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(n.shift(),n.shift(),i=!0):"::"===e.substr(e.length-2)&&(n.pop(),n.pop(),i=!0);for(var u=0;u0&&u=1:n.length===a}return!1}function h(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function g(t,e){for(var o=0;o=2083||/\s/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;o=s(o,yt);var r=void 0,n=void 0,i=void 0,l=void 0,a=void 0,u=void 0,c=void 0,d=void 0;if(c=e.split("#"),e=c.shift(),c=e.split("?"),e=c.shift(),c=e.split("://"),c.length>1){if(r=c.shift(),o.require_valid_protocol&&o.protocols.indexOf(r)===-1)return!1}else{if(o.require_protocol)return!1;o.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(c[0]=e.substr(2))}if(e=c.join("://"),c=e.split("/"),e=c.shift(),""===e&&!o.require_host)return!0;if(c=e.split("@"),c.length>1&&(n=c.shift(),n.indexOf(":")>=0&&n.split(":").length>2))return!1;l=c.join("@"),u=d=null;var h=l.match(At);return h?(i="",d=h[1],u=h[2]||null):(c=l.split(":"),i=c.shift(),c.length&&(u=c.join(":"))),!(null!==u&&(a=parseInt(u,10),!/^[0-9]+$/.test(u)||a<=0||a>65535))&&(!!(p(i)||f(i,o)||d&&p(d,6)||"localhost"===i)&&(i=i||d,!(o.host_whitelist&&!g(i,o.host_whitelist))&&(!o.host_blacklist||!g(i,o.host_blacklist))))}function v(e){return t(e),bt.test(e)}function _(e){return t(e),["true","false","1","0"].indexOf(e)>=0}function F(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in kt)return kt[o].test(e);throw new Error("Invalid locale '"+o+"'")}function $(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(t(e),o in Dt)return Dt[o].test(e);throw new Error("Invalid locale '"+o+"'")}function x(e){return t(e),Ct.test(e)}function w(e){return t(e),e===e.toLowerCase()}function y(e){return t(e),e===e.toUpperCase()}function A(e){return t(e),Rt.test(e)}function b(e){return t(e),jt.test(e)}function k(e){return t(e),zt.test(e)}function D(e){return t(e),jt.test(e)&&zt.test(e)}function S(e){return t(e),Ut.test(e)}function E(e){return t(e),Nt.test(e)}function Z(e,o){t(e),o=o||{};var r=o.hasOwnProperty("allow_leading_zeroes")&&!o.allow_leading_zeroes?Pt:Bt,n=!o.hasOwnProperty("min")||e>=o.min,i=!o.hasOwnProperty("max")||e<=o.max;return r.test(e)&&n&&i}function I(e,o){return t(e),o=o||{},""!==e&&"."!==e&&(Lt.test(e)&&(!o.hasOwnProperty("min")||e>=o.min)&&(!o.hasOwnProperty("max")||e<=o.max)&&(!o.hasOwnProperty("lt")||eo.gt))}function O(e){return t(e),""!==e&&qt.test(e)}function C(e){return t(e),Tt.test(e)}function R(e,r){return t(e),o(e)%parseInt(r,10)===0}function j(e){return t(e),Mt.test(e)}function z(e){return t(e),Ht.test(e)}function U(e){t(e);try{var o=JSON.parse(e);return!!o&&"object"===("undefined"==typeof o?"undefined":pt(o))}catch(t){}return!1}function N(e){return t(e),0===e.length}function P(e,o){t(e);var r=void 0,n=void 0;"object"===("undefined"==typeof o?"undefined":pt(o))?(r=o.min||0,n=o.max):(r=arguments[1],n=arguments[2]);var i=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-i.length;return l>=r&&("undefined"==typeof n||l<=n)}function B(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";t(e);var r=Wt[o];return r&&r.test(e)}function L(e){return t(e),C(e)&&24===e.length}function q(e){return t(e),Yt.test(e)}function T(t){var e=t.match(Yt),o=void 0,r=void 0,n=void 0,i=void 0;if(e){if(o=e[21],!o)return e[12]?null:0;if("z"===o||"Z"===o)return 0;r=e[22],o.indexOf(":")!==-1?(n=parseInt(e[23],10),i=parseInt(e[24],10)):(n=0,i=parseInt(e[23],10))}else{if(t=t.toLowerCase(),o=t.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!o)return t.indexOf("gmt")!==-1?0:null;r=o[1];var l=o[2];3===l.length&&(l="0"+l),l.length<=2?(n=0,i=parseInt(l,10)):(n=parseInt(l.slice(0,2),10),i=parseInt(l.slice(2,4),10))}return(60*n+i)*("-"===r?1:-1)}function M(e){t(e);var o=new Date(Date.parse(e));if(isNaN(o))return!1;var r=T(e);if(null!==r){var n=o.getTimezoneOffset()-r;o=new Date(o.getTime()+6e4*n)}var i=String(o.getDate()),l=void 0,a=void 0,u=void 0;return!(a=e.match(/(^|[^:\d])[23]\d([^T:\d]|$)/g))||(l=a.map(function(t){return t.match(/\d+/g)[0]}).join("/"),u=String(o.getFullYear()).slice(-2),l===i||l===u||(l===""+i/u||l===""+u/i))}function H(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var n=e(r),i=e(o);return!!(i&&n&&i>n)}function W(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var n=e(r),i=e(o);return!!(i&&n&&i=0}return"object"===("undefined"==typeof o?"undefined":pt(o))?o.hasOwnProperty(e):!(!o||"function"!=typeof o.indexOf)&&o.indexOf(e)>=0}function G(e){t(e);var o=e.replace(/[^0-9]+/g,"");if(!Gt.test(o))return!1;for(var r=0,n=void 0,i=void 0,l=void 0,a=o.length-1;a>=0;a--)n=o.substring(a,a+1),i=parseInt(n,10),l?(i*=2,r+=i>=10?i%10+1:i):r+=i,l=!l;return!(r%10!==0||!o)}function J(e){if(t(e),!Jt.test(e))return!1;for(var o=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),r=0,n=void 0,i=void 0,l=!0,a=o.length-2;a>=0;a--)n=o.substring(a,a+1),i=parseInt(n,10),l?(i*=2,r+=i>=10?i+1:i):r+=i,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-r)%10}function K(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),o=String(o),!o)return K(e,10)||K(e,13);var r=e.replace(/[\s-]+/g,""),n=0,i=void 0;if("10"===o){if(!Kt.test(r))return!1;for(i=0;i<9;i++)n+=(i+1)*r.charAt(i);if(n+="X"===r.charAt(9)?100:10*r.charAt(9),n%11===0)return!!r}else if("13"===o){if(!Qt.test(r))return!1;for(i=0;i<12;i++)n+=Vt[i%2]*r.charAt(i);if(r.charAt(12)-(10-n%10)%10===0)return!!r}return!1}function Q(e,o){return t(e),o in Xt&&Xt[o].test(e)}function V(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),o="-?",r="[1-9]\\d*",n="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",i=["0",r,n],l="("+i.join("|")+")?",a="(\\"+t.decimal_separator+"\\d{2})?",u=l+a;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?u+=o:t.negative_sign_before_digits&&(u=o+u)),t.allow_negative_sign_placeholder?u="( (?!\\-))?"+u:t.allow_space_after_symbol?u=" ?"+u:t.allow_space_after_digits&&(u+="( (?!$))?"),t.symbol_after_digits?u+=e:u=e+u,t.allow_negatives&&(t.parens_for_negatives?u="(\\("+u+"\\)|"+u+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(u=o+u)),new RegExp("^(?!-? )(?=.*\\d)"+u+"$")}function X(e,o){return t(e),o=s(o,te),V(o).test(e)}function tt(e){t(e);var o=e.length;if(!o||o%4!==0||ee.test(e))return!1;var r=e.indexOf("=");return r===-1||r===o-1||r===o-2&&"="===e[o-1]}function et(e){return t(e),oe.test(e)}function ot(e,o){t(e);var r=o?new RegExp("^["+o+"]+","g"):/^\s+/g;return e.replace(r,"")}function rt(e,o){t(e);for(var r=o?new RegExp("["+o+"]"):/\s/,n=e.length-1;n>=0&&r.test(e[n]);)n--;return n/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")}function lt(e){return t(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/`/g,"`")}function at(e,o){return t(e),e.replace(new RegExp("["+o+"]+","g"),"")}function ut(e,o){t(e);var r=o?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return at(e,r)}function st(e,o){return t(e),e.replace(new RegExp("[^"+o+"]+","g"),"")}function ct(e,o){t(e);for(var r=e.length-1;r>=0;r--)if(o.indexOf(e[r])===-1)return!1;return!0}function ft(t,e){if(e=s(e,re),!d(t))return!1;var o=t.split("@",2);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,"")),!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(~ne.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(~ie.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(~le.indexOf(o[1])){if(e.yahoo_remove_subaddress){var r=o[0].split("-");o[0]=r.length>1?r.slice(0,-1).join("-"):r[0]}if(!o[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(o[0]=o[0].toLowerCase())}else e.all_lowercase&&(o[0]=o[0].toLowerCase());return o.join("@")}for(var dt,pt="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},ht=(function(){function t(t){this.value=t}function e(e){function o(t,e){return new Promise(function(o,n){var a={key:t,arg:e,resolve:o,reject:n,next:null};l?l=l.next=a:(i=l=a,r(t,e))})}function r(o,i){try{var l=e[o](i),a=l.value;a instanceof t?Promise.resolve(a.value).then(function(t){r("next",t)},function(t){r("throw",t)}):n(l.done?"return":"normal",l.value)}catch(t){n("throw",t)}}function n(t,e){switch(t){case"return":i.resolve({value:e,done:!0});break;case"throw":i.reject(e);break;default:i.resolve({value:e,done:!1})}i=i.next,i?r(i.key,i.arg):l=null}var i,l;this._invoke=o,"function"!=typeof e.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)},{wrap:function(t){return function(){return new e(t.apply(this,arguments))}},await:function(e){return new t(e)}}}(),{require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1}),gt={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},mt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,vt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,_t=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,Ft=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,$t=/^([\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,xt=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,wt=/^[0-9A-F]{1,4}$/i,yt={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},At=/^\[([^\]]+)\](?::([0-9]+))?$/,bt=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,kt={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[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:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Dt={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[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ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},St=["AU","GB","HK","IN","NZ","ZA","ZM"],Et=0;Et