From e4bb29654d1b1f6857da5e08be2c92c829c6d299 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Sun, 14 Oct 2018 18:03:11 +0300 Subject: [PATCH 1/2] fix: extra validation for dates This commit adds an additional test for dates over and above passing the pattern match. It checks to assertain that the date is a valid date. For examples, dates like 2009-02-29 are caught as invalid. Additionally, it also fixes a minor bug with the `weekDate` that was wrongfully leaving out W53 as an invalid date. fixes #772 --- README.md | 2 +- lib/isISO8601.js | 26 ++++++++++++++++++++++++-- src/lib/isISO8601.js | 28 +++++++++++++++++++++++++--- test/validators.js | 7 +++++-- validator.js | 26 ++++++++++++++++++++++++-- validator.min.js | 2 +- 6 files changed, 80 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e951d0eb8..11345a310 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Validator | Description **isISBN(str [, version])** | check if the string is an ISBN (version 10 or 13). **isISSN(str [, options])** | check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).

`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected. **isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier). -**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date. +**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date; with additional checks for valid dates, e.g. invalidates dates like `2009-02-29`. **isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. **isISO31661Alpha2(str)** | check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code. **isISO31661Alpha3(str)** | check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code. diff --git a/lib/isISO8601.js b/lib/isISO8601.js index e38f8611b..d19596025 100644 --- a/lib/isISO8601.js +++ b/lib/isISO8601.js @@ -13,11 +13,33 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de /* eslint-disable max-len */ // from http://goo.gl/0ejHHW -var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; /* eslint-enable max-len */ +var isValidDate = function isValidDate(str) { + // str must have passed the ISO8601 check + // this check is meant to catch invalid dates + // like 2009-02-31 + // note: we choose not to validate the time part + var match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + var year = match[1]; + var month = match[2]; + var day = match[3]; + // create a date object and compare + var d = new Date(year + '-' + (month || 1) + '-' + (day || 1)); + if (isNaN(d.getFullYear())) return false; + if (month && day) { + return d.getFullYear() === year && d.getMonth() + 1 === month && d.getDate() === day; + } + return true; +}; function isISO8601(str) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { strict: true }; + (0, _assertString2.default)(str); - return iso8601.test(str); + var check = iso8601.test(str); + if (!options) return check; + if (check && options.strict) return isValidDate(str); + return check; } module.exports = exports['default']; \ No newline at end of file diff --git a/src/lib/isISO8601.js b/src/lib/isISO8601.js index 7b24e5fe0..8fb572a38 100644 --- a/src/lib/isISO8601.js +++ b/src/lib/isISO8601.js @@ -2,10 +2,32 @@ import assertString from './util/assertString'; /* eslint-disable max-len */ // from http://goo.gl/0ejHHW -const iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +const iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; /* eslint-enable max-len */ +const isValidDate = (str) => { + // str must have passed the ISO8601 check + // this check is meant to catch invalid dates + // like 2009-02-31 + // note: we choose not to validate the time part + const match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + const year = match[1]; + const month = match[2]; + const day = match[3]; + // create a date object and compare + const d = new Date(`${year}-${month || 1}-${day || 1}`); + if (isNaN(d.getFullYear())) return false; + if (month && day) { + return d.getFullYear() === year + && (d.getMonth() + 1) === month + && d.getDate() === day; + } + return true; +}; -export default function isISO8601(str) { +export default function isISO8601(str, options = { strict: true }) { assertString(str); - return iso8601.test(str); + const check = iso8601.test(str); + if (!options) return check; + if (check && options.strict) return isValidDate(str); + return check; } diff --git a/test/validators.js b/test/validators.js index a234b9db8..43d1bfe9e 100644 --- a/test/validators.js +++ b/test/validators.js @@ -5513,7 +5513,7 @@ describe('Validators', () => { '2009123', '2009-05', '2009-123', - '2009-222', + // '2009-222', // invalid test-case, implies 2009-22-2 '2009-001', '2009-W01-1', '2009-W51-1', @@ -5528,7 +5528,7 @@ describe('Validators', () => { '2009-05-19T14:39Z', '2009-W21-2', '2009-W21-2T01:22', - '2009-139', + // '2009-139', // invalid test-case, implies 2009-13-9 '2009-05-19 14:39:22-06:00', '2009-05-19 14:39:22+0600', '2009-05-19 14:39:22-01', @@ -5570,6 +5570,9 @@ describe('Validators', () => { '2009-05-19 14.5.44', '2010-02-18T16:23.33.600', '2010-02-18T16,25:23:48,444', + '2010-13-1', + '2010-02-30', + '2009-02-29', ], }); }); diff --git a/validator.js b/validator.js index 7f82e7805..0164161ca 100644 --- a/validator.js +++ b/validator.js @@ -1305,12 +1305,34 @@ function isCurrency(str, options) { /* eslint-disable max-len */ // from http://goo.gl/0ejHHW -var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; +var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; /* eslint-enable max-len */ +var isValidDate = function isValidDate(str) { + // str must have passed the ISO8601 check + // this check is meant to catch invalid dates + // like 2009-02-31 + // note: we choose not to validate the time part + var match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + var year = match[1]; + var month = match[2]; + var day = match[3]; + // create a date object and compare + var d = new Date(year + '-' + (month || 1) + '-' + (day || 1)); + if (isNaN(d.getFullYear())) return false; + if (month && day) { + return d.getFullYear() === year && d.getMonth() + 1 === month && d.getDate() === day; + } + return true; +}; function isISO8601(str) { + var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { strict: true }; + assertString(str); - return iso8601.test(str); + var check = iso8601.test(str); + if (!options) return check; + if (check && options.strict) return isValidDate(str); + return check; } /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */ diff --git a/validator.min.js b/validator.min.js index e40fdaf86..b610f24c3 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(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function g(e){if(!("string"==typeof e||e instanceof String)){var t=void 0;throw t=null===e?"null":"object"===(t=void 0===e?"undefined":a(e))&&e.constructor&&e.constructor.hasOwnProperty("name")?e.constructor.name:"a "+t,new TypeError("Expected string but received "+t+".")}}function o(e){return g(e),e=Date.parse(e),isNaN(e)?null:new Date(e)}function r(e){return g(e),parseFloat(e)}function n(e){return"object"===(void 0===e?"undefined":a(e))&&null!==e?e="function"==typeof e.toString?e.toString():"[object Object]":(null==e||isNaN(e)&&!e.length)&&(e=""),String(e)}function A(){var e=0n)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;a$/i,F=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,S=/^[a-z\d]+$/,R=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,E=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,x=/^([\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 c={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(e,t){for(var r=0;r=t.min,o=!t.hasOwnProperty("max")||e<=t.max,n=!t.hasOwnProperty("lt")||et.gt;return r.test(e)&&i&&o&&n&&a}var z=/^[\x00-\x7F]+$/;var W=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var V=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/;var Y=/[^\x00-\x7F]/;var j=/[\uD800-\uDBFF][\uDC00-\uDFFF]/;var J=Object.keys(L),q=function(e,t){return e.some(function(e){return t===e})};var Q={force_decimal:!1,decimal_digits:"1,",locale:"en-US"},X=["","-","+"];var ee=/^[0-9A-F]+$/i;function te(e){return g(e),ee.test(e)}var re=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;var ie=/^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/;var oe=/^[a-f0-9]{32}$/;var ne={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 ae=/^([A-Za-z0-9\-_~+\/]+[=]{0,2})\.([A-Za-z0-9\-_~+\/]+[=]{0,2})(?:\.([A-Za-z0-9\-_~+\/]+[=]{0,2}))?$/;var le={ignore_whitespace:!1};var se={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 ue=/^(?: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 de={ES:function(e){g(e);var t={X:0,Y:1,Z:2},r=e.trim().toUpperCase();if(!/^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/.test(r))return!1;var i=r.slice(0,-1).replace(/[X,Y,Z]/g,function(e){return t[e]});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"][i%23])}};var ce=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/;var fe=/^(?:[0-9]{9}X|[0-9]{10})$/,pe=/^(?:[0-9]{13})$/,ge=[1,3];var Ae={"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-IQ":/^(\+?964|0)?7[0-9]\d{8}$/,"ar-JO":/^(\+?962|0)?7[789]\d{7}$/,"ar-KW":/^(\+?965)[569]\d{7}$/,"ar-SA":/^(!?(\+?966)|0)?5\d{8}$/,"ar-SY":/^(!?(\+?963)|0)?9\d{8}$/,"ar-TN":/^(\+?216)?[2459]\d{7}$/,"be-BY":/^(\+?375)?(24|25|29|33|44)\d{7}$/,"bg-BG":/^(\+?359|0)?8[789]\d{7}$/,"bn-BD":/\+?(88)?0?1[156789][0-9]{8}\b/,"cs-CZ":/^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"da-DK":/^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,"de-DE":/^(\+?49[ \.\-]?)?([\(]{1}[0-9]{1,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,"el-GR":/^(\+?30|0)?(69\d{8})$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-HK":/^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,"en-IN":/^(\+?91|0)?[6789]\d{9}$/,"en-KE":/^(\+?254|0)?[7]\d{8}$/,"en-NG":/^(\+?234|0)?[789]\d{9}$/,"en-NZ":/^(\+?64|0)[28]\d{7,9}$/,"en-PK":/^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/,"en-RW":/^(\+?250|0)?[7]\d{8}$/,"en-SG":/^(\+65)?[89]\d{7}$/,"en-TZ":/^(\+?255|0)?[67]\d{8}$/,"en-UG":/^(\+?256|0)?[7]\d{8}$/,"en-US":/^(\+?1?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,"en-ZA":/^(\+?27|0)\d{9}$/,"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-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}$/,"fi-FI":/^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,"fo-FO":/^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"he-IL":/^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/,"hu-HU":/^(\+?36)(20|30|70)\d{7}$/,"id-ID":/^(\+?62|0)(0?8?\d\d\s?\d?)([\s?|\d]{7,12})$/,"it-IT":/^(\+?39)?\s?3\d{2} ?\d{6,7}$/,"ja-JP":/^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,"kk-KZ":/^(\+?7|8)?7\d{9}$/,"kl-GL":/^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,"ko-KR":/^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,"lt-LT":/^(\+370|8)\d{8}$/,"ms-MY":/^(\+?6?01){1}(([145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"nl-BE":/^(\+?32|0)4?\d{8}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"pl-PL":/^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/,"pt-BR":/(?=^(\+?5{2}\-?|0)[1-9]{2}\-?\d{4}\-?\d{4}$)(^(\+?5{2}\-?|0)[1-9]{2}\-?[6-9]{1}\d{3}\-?\d{4}$)|(^(\+?5{2}\-?|0)[1-9]{2}\-?9[6-9]{1}\d{3}\-?\d{4}$)/,"pt-PT":/^(\+?351)?9[1236]\d{7}$/,"ro-RO":/^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"sl-SI":/^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/,"sk-SK":/^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,"sr-RS":/^(\+3816|06)[- \d]{5,9}$/,"sv-SE":/^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/,"th-TH":/^(\+66|66|0)\d{9}$/,"tr-TR":/^(\+?90|0)?5\d{9}$/,"uk-UA":/^(\+?38|8)?0\d{9}$/,"vi-VN":/^(\+?84|0)((3([2-9]))|(5([689]))|(7([0|6-9]))|(8([1-5]))|(9([0-9])))([0-9]{7})$/,"zh-CN":/^((\+|00)86)?1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/};Ae["en-CA"]=Ae["en-US"],Ae["fr-BE"]=Ae["nl-BE"],Ae["zh-HK"]=Ae["en-HK"];var he=Object.keys(Ae);var ve={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_decimal:!0,require_decimal:!1,digits_after_decimal:[2],allow_space_after_digits:!1};var me=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;var $e=/([01][0-9]|2[0-3])/,_e=/[0-5][0-9]/,Fe=new RegExp("[-+]"+$e.source+":"+_e.source),Se=new RegExp("([zZ]|"+Fe.source+")"),Re=new RegExp($e.source+":"+_e.source+":"+/([0-5][0-9]|60)/.source+/(\.[0-9]+)?/.source),Ee=new RegExp(/[0-9]{4}/.source+"-"+/(0[1-9]|1[0-2])/.source+"-"+/([12]\d|0[1-9]|3[01])/.source),xe=new RegExp(""+Re.source+Se.source),Ce=new RegExp(Ee.source+"[ tT]"+xe.source);var Me=["AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AS","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CW","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IR","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","ZA","ZM","ZW"];var we=["AFG","ALA","ALB","DZA","ASM","AND","AGO","AIA","ATA","ATG","ARG","ARM","ABW","AUS","AUT","AZE","BHS","BHR","BGD","BRB","BLR","BEL","BLZ","BEN","BMU","BTN","BOL","BES","BIH","BWA","BVT","BRA","IOT","BRN","BGR","BFA","BDI","KHM","CMR","CAN","CPV","CYM","CAF","TCD","CHL","CHN","CXR","CCK","COL","COM","COG","COD","COK","CRI","CIV","HRV","CUB","CUW","CYP","CZE","DNK","DJI","DMA","DOM","ECU","EGY","SLV","GNQ","ERI","EST","ETH","FLK","FRO","FJI","FIN","FRA","GUF","PYF","ATF","GAB","GMB","GEO","DEU","GHA","GIB","GRC","GRL","GRD","GLP","GUM","GTM","GGY","GIN","GNB","GUY","HTI","HMD","VAT","HND","HKG","HUN","ISL","IND","IDN","IRN","IRQ","IRL","IMN","ISR","ITA","JAM","JPN","JEY","JOR","KAZ","KEN","KIR","PRK","KOR","KWT","KGZ","LAO","LVA","LBN","LSO","LBR","LBY","LIE","LTU","LUX","MAC","MKD","MDG","MWI","MYS","MDV","MLI","MLT","MHL","MTQ","MRT","MUS","MYT","MEX","FSM","MDA","MCO","MNG","MNE","MSR","MAR","MOZ","MMR","NAM","NRU","NPL","NLD","NCL","NZL","NIC","NER","NGA","NIU","NFK","MNP","NOR","OMN","PAK","PLW","PSE","PAN","PNG","PRY","PER","PHL","PCN","POL","PRT","PRI","QAT","REU","ROU","RUS","RWA","BLM","SHN","KNA","LCA","MAF","SPM","VCT","WSM","SMR","STP","SAU","SEN","SRB","SYC","SLE","SGP","SXM","SVK","SVN","SLB","SOM","ZAF","SGS","SSD","ESP","LKA","SDN","SUR","SJM","SWZ","SWE","CHE","SYR","TWN","TJK","TZA","THA","TLS","TGO","TKL","TON","TTO","TUN","TUR","TKM","TCA","TUV","UGA","UKR","ARE","GBR","USA","UMI","URY","UZB","VUT","VEN","VNM","VGB","VIR","WLF","ESH","YEM","ZMB","ZWE"];var Le=/[^A-Z0-9+\/=]/i;var Ne=/^[a-z]+\/[a-z0-9\-\+]+$/i,Ie=/^[a-z\-]+=[a-z0-9\-]+$/i,Ze=/^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i;var Te=/^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i;var Be=/^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i,ye=/^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i,Oe=/^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i;var be=/^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/,De=/^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/,Ge=/^\d{4}$/,Pe=/^\d{5}$/,Ue=/^\d{6}$/,ke={AD:/^AD\d{3}$/,AT:Ge,AU:Ge,BE:Ge,BG:Ge,CA:/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,CH:Ge,CZ:/^\d{3}\s?\d{2}$/,DE:Pe,DK:Ge,DZ:Pe,EE:Pe,ES:Pe,FI:Pe,FR:/^\d{2}\s?\d{3}$/,GB:/^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,GR:/^\d{3}\s?\d{2}$/,HR:/^([1-5]\d{4}$)/,HU:Ge,IL:Pe,IN:Ue,IS:/^\d{3}$/,IT:Pe,JP:/^\d{3}\-\d{4}$/,KE:Pe,LI:/^(948[5-9]|949[0-7])$/,LT:/^LT\-\d{5}$/,LU:Ge,LV:/^LV\-\d{4}$/,MX:Pe,NL:/^\d{4}\s?[a-z]{2}$/i,NO:Ge,PL:/^\d{2}\-\d{3}$/,PT:/^\d{4}\-\d{3}?$/,RO:Ue,RU:Ue,SA:Pe,SE:/^\d{3}\s?\d{2}$/,SI:Ge,SK:/^\d{3}\s?\d{2}$/,TN:Ge,TW:/^\d{3}(\d{2})?$/,US:/^\d{5}(-\d{4})?$/,ZA:Ge,ZM:Pe},Ke=Object.keys(ke);function He(e,t){g(e);var r=t?new RegExp("^["+t+"]+","g"):/^\s+/g;return e.replace(r,"")}function ze(e,t){g(e);for(var r=t?new RegExp("["+t+"]"):/\s/,i=e.length-1;0<=i&&r.test(e[i]);i--);return i]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;t=A(t,c);var r=void 0,i=void 0,o=void 0,n=void 0,a=void 0,l=void 0,s=void 0,u=void 0;if(1<(s=(e=(s=(e=(s=e.split("#")).shift()).split("?")).shift()).split("://")).length){if(r=s.shift().toLowerCase(),t.require_valid_protocol&&-1===t.protocols.indexOf(r))return!1}else{if(t.require_protocol)return!1;if("//"===e.substr(0,2)){if(!t.allow_protocol_relative_urls)return!1;s[0]=e.substr(2)}}if(""===(e=s.join("://")))return!1;if(""===(e=(s=e.split("/")).shift())&&!t.require_host)return!0;if(1<(s=e.split("@")).length){if(t.disallow_auth)return!1;if(0<=(i=s.shift()).indexOf(":")&&2=t.min)&&(!t.hasOwnProperty("max")||i<=t.max)&&(!t.hasOwnProperty("lt")||it.gt)},isFloatLocales:J,isDecimal:function(e,t){if(g(e),(t=A(t,Q)).locale in L)return!q(X,e.replace(/ /g,""))&&(r=t,new RegExp("^[-+]?([0-9]+)?(\\"+L[r.locale]+"[0-9]{"+r.decimal_digits+"})"+(r.force_decimal?"":"?")+"$")).test(e);var r;throw new Error("Invalid locale '"+t.locale+"'")},isHexadecimal:te,isDivisibleBy:function(e,t){return g(e),r(e)%parseInt(t,10)==0},isHexColor:function(e){return g(e),re.test(e)},isISRC:function(e){return g(e),ie.test(e)},isMD5:function(e){return g(e),oe.test(e)},isHash:function(e,t){return g(e),new RegExp("^[a-f0-9]{"+ne[t]+"}$").test(e)},isJWT:function(e){return g(e),ae.test(e)},isJSON:function(e){g(e);try{var t=JSON.parse(e);return!!t&&"object"===(void 0===t?"undefined":a(t))}catch(e){}return!1},isEmpty:function(e,t){return g(e),0===((t=A(t,le)).ignore_whitespace?e.trim().length:e.length)},isLength:function(e,t){g(e);var r=void 0,i=void 0;i="object"===(void 0===t?"undefined":a(t))?(r=t.min||0,t.max):(r=t,arguments[2]);var o=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],n=e.length-o.length;return r<=n&&(void 0===i||n<=i)},isByteLength:h,isUUID:function(e){var t=1/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(e){return g(e),e.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(e,t){return g(e),We(e,t?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(e,t){return g(e),e.replace(new RegExp("[^"+t+"]+","g"),"")},blacklist:We,isWhitelisted:function(e,t){g(e);for(var r=e.length-1;0<=r;r--)if(-1===t.indexOf(e[r]))return!1;return!0},normalizeEmail:function(e,t){t=A(t,Ve);var r=e.split("@"),i=r.pop(),o=[r.join("@"),i];if(o[1]=o[1].toLowerCase(),"gmail.com"===o[1]||"googlemail.com"===o[1]){if(t.gmail_remove_subaddress&&(o[0]=o[0].split("+")[0]),t.gmail_remove_dots&&(o[0]=o[0].replace(/\.+/g,Qe)),!o[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(o[0]=o[0].toLowerCase()),o[1]=t.gmail_convert_googlemaildotcom?"gmail.com":o[1]}else if(0<=Ye.indexOf(o[1])){if(t.icloud_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=je.indexOf(o[1])){if(t.outlookdotcom_remove_subaddress&&(o[0]=o[0].split("+")[0]),!o[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(o[0]=o[0].toLowerCase())}else if(0<=Je.indexOf(o[1])){if(t.yahoo_remove_subaddress){var n=o[0].split("-");o[0]=10&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e}function n(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=i&&(void 0===o||n<=o)}function a(t,r){e(t),(r=o(r,_)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));for(var i=t.split("."),n=0;n63)return!1;if(r.require_tld){var a=i.pop();if(!i.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(a))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(a))return!1}for(var l,s=0;s1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return l(t,4)||l(t,6);if("4"===r){if(!v.test(t))return!1;return t.split(".").sort(function(e,t){return e-t})[3]<=255}if("6"===r){var i=t.split(":"),o=!1,n=l(i[i.length-1],4),a=n?7:8;if(i.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s0&&s=1:i.length===a}return!1}function s(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function u(e,t){for(var r=0;r=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||tr.gt;return i.test(t)&&o&&n&&a&&l}function c(t){return e(t),le.test(t)}function f(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return f(t,10)||f(t,13);var i=t.replace(/[\s-]+/g,""),o=0,n=void 0;if("10"===r){if(!$e.test(i))return!1;for(n=0;n<9;n++)o+=(n+1)*i.charAt(n);if("X"===i.charAt(9)?o+=100:o+=10*i.charAt(9),o%11==0)return!!i}else if("13"===r){if(!_e.test(i))return!1;for(n=0;n<12;n++)o+=ve[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10==0)return!!i}return!1}function p(t,r){e(t);var i=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(i,"")}function g(t,r){e(t);for(var i=r?new RegExp("["+r+"]"):/\s/,o=t.length-1;o>=0&&i.test(t[o]);o--);return o1?e:""}for(var m,$="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},v=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,F=/^[0-9A-F]{1,4}$/i,S={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},R=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/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,C=/^([\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,N={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},L=/^\[([^\]]+)\](?::([0-9]+))?$/,I=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,Z=/^([0-9a-fA-F]){12}$/,T=/^\d{1,2}$/,B={"en-US":/^[A-Z]+$/i,"bg-BG":/^[А-Я]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"el-GR":/^[Α-ω]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[A-ZÀÉÈÌÎÓÒÙ]+$/i,"nb-NO":/^[A-ZÆØÅ]+$/i,"nl-NL":/^[A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[A-ZÆØÅ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sl-SI":/^[A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[A-ZÅÄÖ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},y={"en-US":/^[0-9A-Z]+$/i,"bg-BG":/^[0-9А-Я]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"el-GR":/^[0-9Α-ω]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nb-NO":/^[0-9A-ZÆØÅ]+$/i,"nl-NL":/^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[0-9A-ZÆØÅ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sl-SI":/^[0-9A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[0-9A-ZÅÄÖ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},D={"en-US":".",ar:"٫"},b=["AU","GB","HK","IN","NZ","ZA","ZM"],O=0;O=0},matches:function(t,r,i){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,i)),r.test(t)},isEmail:function(t,r){if(e(t),(r=o(r,S)).require_display_name||r.allow_display_name){var i=t.match(R);if(i)t=i[1];else if(r.require_display_name)return!1}var s=t.split("@"),u=s.pop(),d=s.join("@"),c=u.toLowerCase();if(r.domain_specific_validation&&("gmail.com"===c||"googlemail.com"===c)){var f=(d=d.toLowerCase()).split("+")[0];if(!n(f.replace(".",""),{min:6,max:30}))return!1;for(var p=f.split("."),g=0;g=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=o(r,N);var i=void 0,n=void 0,s=void 0,d=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=t.split("#"),t=p.shift(),p=t.split("?"),t=p.shift(),(p=t.split("://")).length>1){if(i=p.shift().toLowerCase(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;if("//"===t.substr(0,2)){if(!r.allow_protocol_relative_urls)return!1;p[0]=t.substr(2)}}if(""===(t=p.join("://")))return!1;if(p=t.split("/"),""===(t=p.shift())&&!r.require_host)return!0;if((p=t.split("@")).length>1){if(r.disallow_auth)return!1;if((n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1}f=null,g=null;var h=(d=p.join("@")).match(L);return h?(s="",g=h[1],f=h[2]||null):(s=(p=d.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(l(s)||a(s,r)||g&&l(g,6))||(s=s||g,r.host_whitelist&&!u(s,r.host_whitelist)||r.host_blacklist&&u(s,r.host_blacklist)))},isMACAddress:function(t,r){return e(t),r&&r.no_colons?Z.test(t):I.test(t)},isIP:l,isIPRange:function(t){e(t);var r=t.split("/");return 2===r.length&&!!T.test(r[1])&&!(r[1].length>1&&r[1].startsWith("0"))&&l(r[0],4)&&r[1]<=32&&r[1]>=0},isFQDN:a,isBoolean:function(t){return e(t),["true","false","1","0"].indexOf(t)>=0},isAlpha:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in B)return B[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphaLocales:W,isAlphanumeric:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in y)return y[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphanumericLocales:Y,isNumeric:function(t,r){return e(t),r&&r.no_symbols?j.test(t):V.test(t)},isPort:function(e){return d(e,{min:0,max:65535})},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),Q.test(t)},isFullWidth:function(t){return e(t),X.test(t)},isHalfWidth:function(t){return e(t),ee.test(t)},isVariableWidth:function(t){return e(t),X.test(t)&&ee.test(t)},isMultibyte:function(t){return e(t),te.test(t)},isSurrogatePair:function(t){return e(t),re.test(t)},isInt:d,isFloat:function(t,r){e(t),r=r||{};var i=new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\"+(r.locale?D[r.locale]:".")+"[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$");if(""===t||"."===t||"-"===t||"+"===t)return!1;var o=parseFloat(t.replace(",","."));return i.test(t)&&(!r.hasOwnProperty("min")||o>=r.min)&&(!r.hasOwnProperty("max")||o<=r.max)&&(!r.hasOwnProperty("lt")||or.gt)},isFloatLocales:ie,isDecimal:function(t,r){if(e(t),(r=o(r,ne)).locale in D)return!oe(ae,t.replace(/ /g,""))&&function(e){return new RegExp("^[-+]?([0-9]+)?(\\"+D[e.locale]+"[0-9]{"+e.decimal_digits+"})"+(e.force_decimal?"":"?")+"$")}(r).test(t);throw new Error("Invalid locale '"+r.locale+"'")},isHexadecimal:c,isDivisibleBy:function(t,i){return e(t),r(t)%parseInt(i,10)==0},isHexColor:function(t){return e(t),se.test(t)},isISRC:function(t){return e(t),ue.test(t)},isMD5:function(t){return e(t),de.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+ce[r]+"}$").test(t)},isJWT:function(t){return e(t),fe.test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":$(r))}catch(e){}return!1},isEmpty:function(t,r){return e(t),0===((r=o(r,pe)).ignore_whitespace?t.trim().length:t.length)},isLength:function(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=i&&(void 0===o||a<=o)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var i=ge[r];return i&&i.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n>o)},isBefore:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n=0}return"object"===(void 0===r?"undefined":$(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!he.test(r))return!1;for(var i=0,o=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(i%10!=0||!r)},isIdentityCard:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";if(e(t),r in Ae)return Ae[r](t);if("any"===r){for(var i in Ae)if(Ae.hasOwnProperty(i)&&(0,Ae[i])(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isISIN:function(t){if(e(t),!me.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var i=Fe;if(i=r.require_hyphen?i.replace("?",""):i,!(i=r.case_sensitive?new RegExp(i):new RegExp(i,"i")).test(t))return!1;for(var o=t.replace("-","").toUpperCase(),n=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{strict:!0};e(t);var i=xe.test(t);return r&&i&&r.strict?Me(t):i},isRFC3339:function(t){return e(t),Be.test(t)},isISO31661Alpha2:function(t){return e(t),oe(ye,t.toUpperCase())},isISO31661Alpha3:function(t){return e(t),oe(De,t.toUpperCase())},isBase64:function(t){e(t);var r=t.length;if(!r||r%4!=0||be.test(t))return!1;var i=t.indexOf("=");return-1===i||i===r-1||i===r-2&&"="===t[r-1]},isDataURI:function(t){e(t);var r=t.split(",");if(r.length<2)return!1;var i=r.shift().trim().split(";"),o=i.shift();if("data:"!==o.substr(0,5))return!1;var n=o.substr(5);if(""!==n&&!Oe.test(n))return!1;for(var a=0;a/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return e(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,r){return e(t),h(t,r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")},blacklist:h,isWhitelisted:function(t,r){e(t);for(var i=t.length-1;i>=0;i--)if(-1===r.indexOf(t[i]))return!1;return!0},normalizeEmail:function(e,t){t=o(t,qe);var r=e.split("@"),i=r.pop(),n=[r.join("@"),i];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(t.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),t.gmail_remove_dots&&(n[0]=n[0].replace(/\.+/g,A)),!n[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=t.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(Qe.indexOf(n[1])>=0){if(t.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(Xe.indexOf(n[1])>=0){if(t.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(et.indexOf(n[1])>=0){if(t.yahoo_remove_subaddress){var a=n[0].split("-");n[0]=a.length>1?a.slice(0,-1).join("-"):a[0]}if(!n[0].length)return!1;(t.all_lowercase||t.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else tt.indexOf(n[1])>=0?((t.all_lowercase||t.yandex_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]="yandex.ru"):t.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:i}}); \ No newline at end of file From f3bb0cd71a1fe3d57b5594127ed804ff5d1a57d2 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Mon, 15 Oct 2018 11:37:49 +0300 Subject: [PATCH 2/2] fix: add extra validation for ordinal dates - adds provision for ordinal dates - checks that ordinal dates are also valid for leap years - includes regression tests for previous cases with `strict = false` --- README.md | 2 +- lib/isISO8601.js | 18 +++-- src/lib/isISO8601.js | 15 +++- test/validators.js | 162 ++++++++++++++++++++++++++----------------- validator.js | 18 +++-- validator.min.js | 2 +- 6 files changed, 137 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 11345a310..3080ee4bb 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ Validator | Description **isISBN(str [, version])** | check if the string is an ISBN (version 10 or 13). **isISSN(str [, options])** | check if the string is an [ISSN](https://en.wikipedia.org/wiki/International_Standard_Serial_Number).

`options` is an object which defaults to `{ case_sensitive: false, require_hyphen: false }`. If `case_sensitive` is true, ISSNs with a lowercase `'x'` as the check digit are rejected. **isISIN(str)** | check if the string is an [ISIN][ISIN] (stock/security identifier). -**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date; with additional checks for valid dates, e.g. invalidates dates like `2009-02-29`. +**isISO8601(str)** | check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date; for additional checks for valid dates, e.g. invalidates dates like `2009-02-29`, pass `options` object as a second parameter with `options.strict = true`. **isRFC3339(str)** | check if the string is a valid [RFC 3339](https://tools.ietf.org/html/rfc3339) date. **isISO31661Alpha2(str)** | check if the string is a valid [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) officially assigned country code. **isISO31661Alpha3(str)** | check if the string is a valid [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) officially assigned country code. diff --git a/lib/isISO8601.js b/lib/isISO8601.js index d19596025..c37cf6d7f 100644 --- a/lib/isISO8601.js +++ b/lib/isISO8601.js @@ -19,8 +19,18 @@ var isValidDate = function isValidDate(str) { // str must have passed the ISO8601 check // this check is meant to catch invalid dates // like 2009-02-31 - // note: we choose not to validate the time part - var match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + // first check for ordinal dates + var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/); + if (ordinalMatch) { + var oYear = Number(ordinalMatch[1]); + var oDay = Number(ordinalMatch[2]); + // if is leap year + if (oYear % 4 === 0 && oYear % 100 !== 0) { + return oDay <= 366; + } + return oDay <= 365; + } + var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number); var year = match[1]; var month = match[2]; var day = match[3]; @@ -33,9 +43,7 @@ var isValidDate = function isValidDate(str) { return true; }; -function isISO8601(str) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { strict: true }; - +function isISO8601(str, options) { (0, _assertString2.default)(str); var check = iso8601.test(str); if (!options) return check; diff --git a/src/lib/isISO8601.js b/src/lib/isISO8601.js index 8fb572a38..56b967320 100644 --- a/src/lib/isISO8601.js +++ b/src/lib/isISO8601.js @@ -8,8 +8,17 @@ const isValidDate = (str) => { // str must have passed the ISO8601 check // this check is meant to catch invalid dates // like 2009-02-31 - // note: we choose not to validate the time part - const match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + // first check for ordinal dates + const ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/); + if (ordinalMatch) { + const oYear = Number(ordinalMatch[1]); + const oDay = Number(ordinalMatch[2]); + // if is leap year + if (oYear % 4 === 0 + && oYear % 100 !== 0) return oDay <= 366; + return oDay <= 365; + } + const match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number); const year = match[1]; const month = match[2]; const day = match[3]; @@ -24,7 +33,7 @@ const isValidDate = (str) => { return true; }; -export default function isISO8601(str, options = { strict: true }) { +export default function isISO8601(str, options) { assertString(str); const check = iso8601.test(str); if (!options) return check; diff --git a/test/validators.js b/test/validators.js index 43d1bfe9e..d3cbfa134 100644 --- a/test/validators.js +++ b/test/validators.js @@ -5500,79 +5500,111 @@ describe('Validators', () => { }); }); + const validISO8601 = [ + '2009-12T12:34', + '2009', + '2009-05-19', + '2009-05-19', + '20090519', + '2009123', + '2009-05', + '2009-123', + '2009-222', + '2009-001', + '2009-W01-1', + '2009-W51-1', + '2009-W511', + '2009-W33', + '2009W511', + '2009-05-19', + '2009-05-19 00:00', + '2009-05-19 14', + '2009-05-19 14:31', + '2009-05-19 14:39:22', + '2009-05-19T14:39Z', + '2009-W21-2', + '2009-W21-2T01:22', + '2009-139', + '2009-05-19 14:39:22-06:00', + '2009-05-19 14:39:22+0600', + '2009-05-19 14:39:22-01', + '20090621T0545Z', + '2007-04-06T00:00', + '2007-04-05T24:00', + '2010-02-18T16:23:48.5', + '2010-02-18T16:23:48,444', + '2010-02-18T16:23:48,3-06:00', + '2010-02-18T16:23.4', + '2010-02-18T16:23,25', + '2010-02-18T16:23.33+0600', + '2010-02-18T16.23334444', + '2010-02-18T16,2283', + '2009-05-19 143922.500', + '2009-05-19 1439,55', + ]; + + const invalidISO8601 = [ + '200905', + '2009367', + '2009-', + '2007-04-05T24:50', + '2009-000', + '2009-M511', + '2009M511', + '2009-05-19T14a39r', + '2009-05-19T14:3924', + '2009-0519', + '2009-05-1914:39', + '2009-05-19 14:', + '2009-05-19r14:39', + '2009-05-19 14a39a22', + '200912-01', + '2009-05-19 14:39:22+06a00', + '2009-05-19 146922.500', + '2010-02-18T16.5:23.35:48', + '2010-02-18T16:23.35:48', + '2010-02-18T16:23.35:48.45', + '2009-05-19 14.5.44', + '2010-02-18T16:23.33.600', + '2010-02-18T16,25:23:48,444', + '2010-13-1', + ]; + it('should validate ISO 8601 dates', () => { // from http://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/ test({ validator: 'isISO8601', + valid: validISO8601, + invalid: invalidISO8601, + }); + }); + + it('should validate ISO 8601 dates, with strict = true (regression)', () => { + test({ + validator: 'isISO8601', + args: [ + { strict: true }, + ], + valid: validISO8601, + invalid: invalidISO8601, + }); + }); + + it('should validate ISO 8601 dates, with strict = true', () => { + test({ + validator: 'isISO8601', + args: [ + { strict: true }, + ], valid: [ - '2009-12T12:34', - '2009', - '2009-05-19', - '2009-05-19', - '20090519', - '2009123', - '2009-05', + '2000-02-29', '2009-123', - // '2009-222', // invalid test-case, implies 2009-22-2 - '2009-001', - '2009-W01-1', - '2009-W51-1', - '2009-W511', - '2009-W33', - '2009W511', - '2009-05-19', - '2009-05-19 00:00', - '2009-05-19 14', - '2009-05-19 14:31', - '2009-05-19 14:39:22', - '2009-05-19T14:39Z', - '2009-W21-2', - '2009-W21-2T01:22', - // '2009-139', // invalid test-case, implies 2009-13-9 - '2009-05-19 14:39:22-06:00', - '2009-05-19 14:39:22+0600', - '2009-05-19 14:39:22-01', - '20090621T0545Z', - '2007-04-06T00:00', - '2007-04-05T24:00', - '2010-02-18T16:23:48.5', - '2010-02-18T16:23:48,444', - '2010-02-18T16:23:48,3-06:00', - '2010-02-18T16:23.4', - '2010-02-18T16:23,25', - '2010-02-18T16:23.33+0600', - '2010-02-18T16.23334444', - '2010-02-18T16,2283', - '2009-05-19 143922.500', - '2009-05-19 1439,55', - ], - invalid: [ - '200905', - '2009367', - '2009-', - '2007-04-05T24:50', - '2009-000', - '2009-M511', - '2009M511', - '2009-05-19T14a39r', - '2009-05-19T14:3924', - '2009-0519', - '2009-05-1914:39', - '2009-05-19 14:', - '2009-05-19r14:39', - '2009-05-19 14a39a22', - '200912-01', - '2009-05-19 14:39:22+06a00', - '2009-05-19 146922.500', - '2010-02-18T16.5:23.35:48', - '2010-02-18T16:23.35:48', - '2010-02-18T16:23.35:48.45', - '2009-05-19 14.5.44', - '2010-02-18T16:23.33.600', - '2010-02-18T16,25:23:48,444', - '2010-13-1', + '2009-222', + ], + invalid: [ '2010-02-30', '2009-02-29', + '2009-366', ], }); }); diff --git a/validator.js b/validator.js index 0164161ca..7d1f9c59a 100644 --- a/validator.js +++ b/validator.js @@ -1311,8 +1311,18 @@ var isValidDate = function isValidDate(str) { // str must have passed the ISO8601 check // this check is meant to catch invalid dates // like 2009-02-31 - // note: we choose not to validate the time part - var match = str.match(/(\d{4})-?(\d{0,2})-?(\d{0,2})/).map(Number); + // first check for ordinal dates + var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/); + if (ordinalMatch) { + var oYear = Number(ordinalMatch[1]); + var oDay = Number(ordinalMatch[2]); + // if is leap year + if (oYear % 4 === 0 && oYear % 100 !== 0) { + return oDay <= 366; + } + return oDay <= 365; + } + var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number); var year = match[1]; var month = match[2]; var day = match[3]; @@ -1325,9 +1335,7 @@ var isValidDate = function isValidDate(str) { return true; }; -function isISO8601(str) { - var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { strict: true }; - +function isISO8601(str, options) { assertString(str); var check = iso8601.test(str); if (!options) return check; diff --git a/validator.min.js b/validator.min.js index b610f24c3..3689b3148 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(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";function e(e){if(!("string"==typeof e||e instanceof String)){var t=void 0;throw t=null===e?"null":"object"===(t=void 0===e?"undefined":$(e))&&e.constructor&&e.constructor.hasOwnProperty("name")?e.constructor.name:"a "+t,new TypeError("Expected string but received "+t+".")}}function t(t){return e(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function r(t){return e(t),parseFloat(t)}function i(e){return"object"===(void 0===e?"undefined":$(e))&&null!==e?e="function"==typeof e.toString?e.toString():"[object Object]":(null===e||void 0===e||isNaN(e)&&!e.length)&&(e=""),String(e)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e}function n(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=i&&(void 0===o||n<=o)}function a(t,r){e(t),(r=o(r,_)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));for(var i=t.split("."),n=0;n63)return!1;if(r.require_tld){var a=i.pop();if(!i.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(a))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(a))return!1}for(var l,s=0;s1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return l(t,4)||l(t,6);if("4"===r){if(!v.test(t))return!1;return t.split(".").sort(function(e,t){return e-t})[3]<=255}if("6"===r){var i=t.split(":"),o=!1,n=l(i[i.length-1],4),a=n?7:8;if(i.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s0&&s=1:i.length===a}return!1}function s(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function u(e,t){for(var r=0;r=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||tr.gt;return i.test(t)&&o&&n&&a&&l}function c(t){return e(t),le.test(t)}function f(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return f(t,10)||f(t,13);var i=t.replace(/[\s-]+/g,""),o=0,n=void 0;if("10"===r){if(!$e.test(i))return!1;for(n=0;n<9;n++)o+=(n+1)*i.charAt(n);if("X"===i.charAt(9)?o+=100:o+=10*i.charAt(9),o%11==0)return!!i}else if("13"===r){if(!_e.test(i))return!1;for(n=0;n<12;n++)o+=ve[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10==0)return!!i}return!1}function p(t,r){e(t);var i=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(i,"")}function g(t,r){e(t);for(var i=r?new RegExp("["+r+"]"):/\s/,o=t.length-1;o>=0&&i.test(t[o]);o--);return o1?e:""}for(var m,$="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},v=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,F=/^[0-9A-F]{1,4}$/i,S={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},R=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/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,C=/^([\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,N={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},L=/^\[([^\]]+)\](?::([0-9]+))?$/,I=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,Z=/^([0-9a-fA-F]){12}$/,T=/^\d{1,2}$/,B={"en-US":/^[A-Z]+$/i,"bg-BG":/^[А-Я]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"el-GR":/^[Α-ω]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[A-ZÀÉÈÌÎÓÒÙ]+$/i,"nb-NO":/^[A-ZÆØÅ]+$/i,"nl-NL":/^[A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[A-ZÆØÅ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sl-SI":/^[A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[A-ZÅÄÖ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},y={"en-US":/^[0-9A-Z]+$/i,"bg-BG":/^[0-9А-Я]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"el-GR":/^[0-9Α-ω]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nb-NO":/^[0-9A-ZÆØÅ]+$/i,"nl-NL":/^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[0-9A-ZÆØÅ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sl-SI":/^[0-9A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[0-9A-ZÅÄÖ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},D={"en-US":".",ar:"٫"},b=["AU","GB","HK","IN","NZ","ZA","ZM"],O=0;O=0},matches:function(t,r,i){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,i)),r.test(t)},isEmail:function(t,r){if(e(t),(r=o(r,S)).require_display_name||r.allow_display_name){var i=t.match(R);if(i)t=i[1];else if(r.require_display_name)return!1}var s=t.split("@"),u=s.pop(),d=s.join("@"),c=u.toLowerCase();if(r.domain_specific_validation&&("gmail.com"===c||"googlemail.com"===c)){var f=(d=d.toLowerCase()).split("+")[0];if(!n(f.replace(".",""),{min:6,max:30}))return!1;for(var p=f.split("."),g=0;g=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=o(r,N);var i=void 0,n=void 0,s=void 0,d=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=t.split("#"),t=p.shift(),p=t.split("?"),t=p.shift(),(p=t.split("://")).length>1){if(i=p.shift().toLowerCase(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;if("//"===t.substr(0,2)){if(!r.allow_protocol_relative_urls)return!1;p[0]=t.substr(2)}}if(""===(t=p.join("://")))return!1;if(p=t.split("/"),""===(t=p.shift())&&!r.require_host)return!0;if((p=t.split("@")).length>1){if(r.disallow_auth)return!1;if((n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1}f=null,g=null;var h=(d=p.join("@")).match(L);return h?(s="",g=h[1],f=h[2]||null):(s=(p=d.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(l(s)||a(s,r)||g&&l(g,6))||(s=s||g,r.host_whitelist&&!u(s,r.host_whitelist)||r.host_blacklist&&u(s,r.host_blacklist)))},isMACAddress:function(t,r){return e(t),r&&r.no_colons?Z.test(t):I.test(t)},isIP:l,isIPRange:function(t){e(t);var r=t.split("/");return 2===r.length&&!!T.test(r[1])&&!(r[1].length>1&&r[1].startsWith("0"))&&l(r[0],4)&&r[1]<=32&&r[1]>=0},isFQDN:a,isBoolean:function(t){return e(t),["true","false","1","0"].indexOf(t)>=0},isAlpha:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in B)return B[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphaLocales:W,isAlphanumeric:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in y)return y[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphanumericLocales:Y,isNumeric:function(t,r){return e(t),r&&r.no_symbols?j.test(t):V.test(t)},isPort:function(e){return d(e,{min:0,max:65535})},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),Q.test(t)},isFullWidth:function(t){return e(t),X.test(t)},isHalfWidth:function(t){return e(t),ee.test(t)},isVariableWidth:function(t){return e(t),X.test(t)&&ee.test(t)},isMultibyte:function(t){return e(t),te.test(t)},isSurrogatePair:function(t){return e(t),re.test(t)},isInt:d,isFloat:function(t,r){e(t),r=r||{};var i=new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\"+(r.locale?D[r.locale]:".")+"[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$");if(""===t||"."===t||"-"===t||"+"===t)return!1;var o=parseFloat(t.replace(",","."));return i.test(t)&&(!r.hasOwnProperty("min")||o>=r.min)&&(!r.hasOwnProperty("max")||o<=r.max)&&(!r.hasOwnProperty("lt")||or.gt)},isFloatLocales:ie,isDecimal:function(t,r){if(e(t),(r=o(r,ne)).locale in D)return!oe(ae,t.replace(/ /g,""))&&function(e){return new RegExp("^[-+]?([0-9]+)?(\\"+D[e.locale]+"[0-9]{"+e.decimal_digits+"})"+(e.force_decimal?"":"?")+"$")}(r).test(t);throw new Error("Invalid locale '"+r.locale+"'")},isHexadecimal:c,isDivisibleBy:function(t,i){return e(t),r(t)%parseInt(i,10)==0},isHexColor:function(t){return e(t),se.test(t)},isISRC:function(t){return e(t),ue.test(t)},isMD5:function(t){return e(t),de.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+ce[r]+"}$").test(t)},isJWT:function(t){return e(t),fe.test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":$(r))}catch(e){}return!1},isEmpty:function(t,r){return e(t),0===((r=o(r,pe)).ignore_whitespace?t.trim().length:t.length)},isLength:function(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=i&&(void 0===o||a<=o)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var i=ge[r];return i&&i.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n>o)},isBefore:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n=0}return"object"===(void 0===r?"undefined":$(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!he.test(r))return!1;for(var i=0,o=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(i%10!=0||!r)},isIdentityCard:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";if(e(t),r in Ae)return Ae[r](t);if("any"===r){for(var i in Ae)if(Ae.hasOwnProperty(i)&&(0,Ae[i])(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isISIN:function(t){if(e(t),!me.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var i=Fe;if(i=r.require_hyphen?i.replace("?",""):i,!(i=r.case_sensitive?new RegExp(i):new RegExp(i,"i")).test(t))return!1;for(var o=t.replace("-","").toUpperCase(),n=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{strict:!0};e(t);var i=xe.test(t);return r&&i&&r.strict?Me(t):i},isRFC3339:function(t){return e(t),Be.test(t)},isISO31661Alpha2:function(t){return e(t),oe(ye,t.toUpperCase())},isISO31661Alpha3:function(t){return e(t),oe(De,t.toUpperCase())},isBase64:function(t){e(t);var r=t.length;if(!r||r%4!=0||be.test(t))return!1;var i=t.indexOf("=");return-1===i||i===r-1||i===r-2&&"="===t[r-1]},isDataURI:function(t){e(t);var r=t.split(",");if(r.length<2)return!1;var i=r.shift().trim().split(";"),o=i.shift();if("data:"!==o.substr(0,5))return!1;var n=o.substr(5);if(""!==n&&!Oe.test(n))return!1;for(var a=0;a/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return e(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,r){return e(t),h(t,r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")},blacklist:h,isWhitelisted:function(t,r){e(t);for(var i=t.length-1;i>=0;i--)if(-1===r.indexOf(t[i]))return!1;return!0},normalizeEmail:function(e,t){t=o(t,qe);var r=e.split("@"),i=r.pop(),n=[r.join("@"),i];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(t.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),t.gmail_remove_dots&&(n[0]=n[0].replace(/\.+/g,A)),!n[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=t.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(Qe.indexOf(n[1])>=0){if(t.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(Xe.indexOf(n[1])>=0){if(t.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(et.indexOf(n[1])>=0){if(t.yahoo_remove_subaddress){var a=n[0].split("-");n[0]=a.length>1?a.slice(0,-1).join("-"):a[0]}if(!n[0].length)return!1;(t.all_lowercase||t.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else tt.indexOf(n[1])>=0?((t.all_lowercase||t.yandex_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]="yandex.ru"):t.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:i}}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.validator=t()}(this,function(){"use strict";function e(e){if(!("string"==typeof e||e instanceof String)){var t=void 0;throw t=null===e?"null":"object"===(t=void 0===e?"undefined":$(e))&&e.constructor&&e.constructor.hasOwnProperty("name")?e.constructor.name:"a "+t,new TypeError("Expected string but received "+t+".")}}function t(t){return e(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function r(t){return e(t),parseFloat(t)}function i(e){return"object"===(void 0===e?"undefined":$(e))&&null!==e?e="function"==typeof e.toString?e.toString():"[object Object]":(null===e||void 0===e||isNaN(e)&&!e.length)&&(e=""),String(e)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e}function n(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=encodeURI(t).split(/%..|./).length-1;return n>=i&&(void 0===o||n<=o)}function a(t,r){e(t),(r=o(r,_)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));for(var i=t.split("."),n=0;n63)return!1;if(r.require_tld){var a=i.pop();if(!i.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(a))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(a))return!1}for(var l,s=0;s1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return l(t,4)||l(t,6);if("4"===r){if(!v.test(t))return!1;return t.split(".").sort(function(e,t){return e-t})[3]<=255}if("6"===r){var i=t.split(":"),o=!1,n=l(i[i.length-1],4),a=n?7:8;if(i.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===t.substr(t.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s0&&s=1:i.length===a}return!1}function s(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function u(e,t){for(var r=0;r=r.min,n=!r.hasOwnProperty("max")||t<=r.max,a=!r.hasOwnProperty("lt")||tr.gt;return i.test(t)&&o&&n&&a&&l}function c(t){return e(t),le.test(t)}function f(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),!(r=String(r)))return f(t,10)||f(t,13);var i=t.replace(/[\s-]+/g,""),o=0,n=void 0;if("10"===r){if(!$e.test(i))return!1;for(n=0;n<9;n++)o+=(n+1)*i.charAt(n);if("X"===i.charAt(9)?o+=100:o+=10*i.charAt(9),o%11==0)return!!i}else if("13"===r){if(!_e.test(i))return!1;for(n=0;n<12;n++)o+=ve[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10==0)return!!i}return!1}function p(t,r){e(t);var i=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(i,"")}function g(t,r){e(t);for(var i=r?new RegExp("["+r+"]"):/\s/,o=t.length-1;o>=0&&i.test(t[o]);o--);return o1?e:""}for(var m,$="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},v=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,F=/^[0-9A-F]{1,4}$/i,S={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},R=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,E=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,x=/^[a-z\d]+$/,N=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,M=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,w=/^([\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,C={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},L=/^\[([^\]]+)\](?::([0-9]+))?$/,I=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,Z=/^([0-9a-fA-F]){12}$/,T=/^\d{1,2}$/,B={"en-US":/^[A-Z]+$/i,"bg-BG":/^[А-Я]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"el-GR":/^[Α-ω]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[A-ZÀÉÈÌÎÓÒÙ]+$/i,"nb-NO":/^[A-ZÆØÅ]+$/i,"nl-NL":/^[A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[A-ZÆØÅ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sl-SI":/^[A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[A-ZÅÄÖ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},y={"en-US":/^[0-9A-Z]+$/i,"bg-BG":/^[0-9А-Я]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"el-GR":/^[0-9Α-ω]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"it-IT":/^[0-9A-ZÀÉÈÌÎÓÒÙ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nb-NO":/^[0-9A-ZÆØÅ]+$/i,"nl-NL":/^[0-9A-ZÁÉËÏÓÖÜÚ]+$/i,"nn-NO":/^[0-9A-ZÆØÅ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sl-SI":/^[0-9A-ZČĆĐŠŽ]+$/i,"sk-SK":/^[0-9A-ZÁČĎÉÍŇÓŠŤÚÝŽĹŔĽÄÔ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"sv-SE":/^[0-9A-ZÅÄÖ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐі]+$/i,"ku-IQ":/^[٠١٢٣٤٥٦٧٨٩0-9ئابپتجچحخدرڕزژسشعغفڤقکگلڵمنوۆھەیێيطؤثآإأكضصةظذ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},b={"en-US":".",ar:"٫"},D=["AU","GB","HK","IN","NZ","ZA","ZM"],O=0;O=0},matches:function(t,r,i){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,i)),r.test(t)},isEmail:function(t,r){if(e(t),(r=o(r,S)).require_display_name||r.allow_display_name){var i=t.match(R);if(i)t=i[1];else if(r.require_display_name)return!1}var s=t.split("@"),u=s.pop(),d=s.join("@"),c=u.toLowerCase();if(r.domain_specific_validation&&("gmail.com"===c||"googlemail.com"===c)){var f=(d=d.toLowerCase()).split("+")[0];if(!n(f.replace(".",""),{min:6,max:30}))return!1;for(var p=f.split("."),g=0;g=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=o(r,C);var i=void 0,n=void 0,s=void 0,d=void 0,c=void 0,f=void 0,p=void 0,g=void 0;if(p=t.split("#"),t=p.shift(),p=t.split("?"),t=p.shift(),(p=t.split("://")).length>1){if(i=p.shift().toLowerCase(),r.require_valid_protocol&&-1===r.protocols.indexOf(i))return!1}else{if(r.require_protocol)return!1;if("//"===t.substr(0,2)){if(!r.allow_protocol_relative_urls)return!1;p[0]=t.substr(2)}}if(""===(t=p.join("://")))return!1;if(p=t.split("/"),""===(t=p.shift())&&!r.require_host)return!0;if((p=t.split("@")).length>1){if(r.disallow_auth)return!1;if((n=p.shift()).indexOf(":")>=0&&n.split(":").length>2)return!1}f=null,g=null;var h=(d=p.join("@")).match(L);return h?(s="",g=h[1],f=h[2]||null):(s=(p=d.split(":")).shift(),p.length&&(f=p.join(":"))),!(null!==f&&(c=parseInt(f,10),!/^[0-9]+$/.test(f)||c<=0||c>65535)||!(l(s)||a(s,r)||g&&l(g,6))||(s=s||g,r.host_whitelist&&!u(s,r.host_whitelist)||r.host_blacklist&&u(s,r.host_blacklist)))},isMACAddress:function(t,r){return e(t),r&&r.no_colons?Z.test(t):I.test(t)},isIP:l,isIPRange:function(t){e(t);var r=t.split("/");return 2===r.length&&!!T.test(r[1])&&!(r[1].length>1&&r[1].startsWith("0"))&&l(r[0],4)&&r[1]<=32&&r[1]>=0},isFQDN:a,isBoolean:function(t){return e(t),["true","false","1","0"].indexOf(t)>=0},isAlpha:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in B)return B[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphaLocales:W,isAlphanumeric:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in y)return y[r].test(t);throw new Error("Invalid locale '"+r+"'")},isAlphanumericLocales:Y,isNumeric:function(t,r){return e(t),r&&r.no_symbols?j.test(t):V.test(t)},isPort:function(e){return d(e,{min:0,max:65535})},isLowercase:function(t){return e(t),t===t.toLowerCase()},isUppercase:function(t){return e(t),t===t.toUpperCase()},isAscii:function(t){return e(t),Q.test(t)},isFullWidth:function(t){return e(t),X.test(t)},isHalfWidth:function(t){return e(t),ee.test(t)},isVariableWidth:function(t){return e(t),X.test(t)&&ee.test(t)},isMultibyte:function(t){return e(t),te.test(t)},isSurrogatePair:function(t){return e(t),re.test(t)},isInt:d,isFloat:function(t,r){e(t),r=r||{};var i=new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\"+(r.locale?b[r.locale]:".")+"[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$");if(""===t||"."===t||"-"===t||"+"===t)return!1;var o=parseFloat(t.replace(",","."));return i.test(t)&&(!r.hasOwnProperty("min")||o>=r.min)&&(!r.hasOwnProperty("max")||o<=r.max)&&(!r.hasOwnProperty("lt")||or.gt)},isFloatLocales:ie,isDecimal:function(t,r){if(e(t),(r=o(r,ne)).locale in b)return!oe(ae,t.replace(/ /g,""))&&function(e){return new RegExp("^[-+]?([0-9]+)?(\\"+b[e.locale]+"[0-9]{"+e.decimal_digits+"})"+(e.force_decimal?"":"?")+"$")}(r).test(t);throw new Error("Invalid locale '"+r.locale+"'")},isHexadecimal:c,isDivisibleBy:function(t,i){return e(t),r(t)%parseInt(i,10)==0},isHexColor:function(t){return e(t),se.test(t)},isISRC:function(t){return e(t),ue.test(t)},isMD5:function(t){return e(t),de.test(t)},isHash:function(t,r){return e(t),new RegExp("^[a-f0-9]{"+ce[r]+"}$").test(t)},isJWT:function(t){return e(t),fe.test(t)},isJSON:function(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===(void 0===r?"undefined":$(r))}catch(e){}return!1},isEmpty:function(t,r){return e(t),0===((r=o(r,pe)).ignore_whitespace?t.trim().length:t.length)},isLength:function(t,r){e(t);var i=void 0,o=void 0;"object"===(void 0===r?"undefined":$(r))?(i=r.min||0,o=r.max):(i=arguments[1],o=arguments[2]);var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],a=t.length-n.length;return a>=i&&(void 0===o||a<=o)},isByteLength:n,isUUID:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var i=ge[r];return i&&i.test(t)},isMongoId:function(t){return e(t),c(t)&&24===t.length},isAfter:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n>o)},isBefore:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var o=t(i),n=t(r);return!!(n&&o&&n=0}return"object"===(void 0===r?"undefined":$(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0},isCreditCard:function(t){e(t);var r=t.replace(/[- ]+/g,"");if(!he.test(r))return!1;for(var i=0,o=void 0,n=void 0,a=void 0,l=r.length-1;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n%10+1:n,a=!a;return!(i%10!=0||!r)},isIdentityCard:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"any";if(e(t),r in Ae)return Ae[r](t);if("any"===r){for(var i in Ae)if(Ae.hasOwnProperty(i)&&(0,Ae[i])(t))return!0;return!1}throw new Error("Invalid locale '"+r+"'")},isISIN:function(t){if(e(t),!me.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),i=0,o=void 0,n=void 0,a=!0,l=r.length-2;l>=0;l--)o=r.substring(l,l+1),n=parseInt(o,10),i+=a&&(n*=2)>=10?n+1:n,a=!a;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},isISBN:f,isISSN:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var i=Fe;if(i=r.require_hyphen?i.replace("?",""):i,!(i=r.case_sensitive?new RegExp(i):new RegExp(i,"i")).test(t))return!1;for(var o=t.replace("-","").toUpperCase(),n=0,a=0;a/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")},unescape:function(t){return e(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/\/g,"\\").replace(/`/g,"`")},stripLow:function(t,r){return e(t),h(t,r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")},whitelist:function(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")},blacklist:h,isWhitelisted:function(t,r){e(t);for(var i=t.length-1;i>=0;i--)if(-1===r.indexOf(t[i]))return!1;return!0},normalizeEmail:function(e,t){t=o(t,qe);var r=e.split("@"),i=r.pop(),n=[r.join("@"),i];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(t.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),t.gmail_remove_dots&&(n[0]=n[0].replace(/\.+/g,A)),!n[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=t.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(Qe.indexOf(n[1])>=0){if(t.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(Xe.indexOf(n[1])>=0){if(t.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(et.indexOf(n[1])>=0){if(t.yahoo_remove_subaddress){var a=n[0].split("-");n[0]=a.length>1?a.slice(0,-1).join("-"):a[0]}if(!n[0].length)return!1;(t.all_lowercase||t.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else tt.indexOf(n[1])>=0?((t.all_lowercase||t.yandex_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]="yandex.ru"):t.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")},toString:i}}); \ No newline at end of file