From 851517acfc226a490961955473802d404c878df4 Mon Sep 17 00:00:00 2001 From: Abraham Makovetsky Date: Tue, 9 May 2017 19:13:40 +0300 Subject: [PATCH] Added validation for ISRC strings --- index.js | 5 +++++ lib/isISRC.js | 21 +++++++++++++++++++++ src/index.js | 3 +++ src/lib/isISRC.js | 9 +++++++++ test/validators.js | 18 ++++++++++++++++++ validator.js | 9 +++++++++ validator.min.js | 2 +- 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 lib/isISRC.js create mode 100644 src/lib/isISRC.js diff --git a/index.js b/index.js index b08a1263b..2ac00af4a 100644 --- a/index.js +++ b/index.js @@ -124,6 +124,10 @@ var _isHexColor = require('./lib/isHexColor'); var _isHexColor2 = _interopRequireDefault(_isHexColor); +var _isISRC = require('./lib/isISRC'); + +var _isISRC2 = _interopRequireDefault(_isISRC); + var _isMD = require('./lib/isMD5'); var _isMD2 = _interopRequireDefault(_isMD); @@ -280,6 +284,7 @@ var validator = { isHexadecimal: _isHexadecimal2.default, isDivisibleBy: _isDivisibleBy2.default, isHexColor: _isHexColor2.default, + isISRC: _isISRC2.default, isMD5: _isMD2.default, isJSON: _isJSON2.default, isEmpty: _isEmpty2.default, diff --git a/lib/isISRC.js b/lib/isISRC.js new file mode 100644 index 000000000..b567cec43 --- /dev/null +++ b/lib/isISRC.js @@ -0,0 +1,21 @@ +'use strict'; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = isISRC; + +var _assertString = require('./util/assertString'); + +var _assertString2 = _interopRequireDefault(_assertString); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// see http://isrc.ifpi.org/en/isrc-standard/code-syntax +var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/; + +function isISRC(str) { + (0, _assertString2.default)(str); + return isrc.test(str); +} +module.exports = exports['default']; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 06b0a6688..e3ea3d317 100644 --- a/src/index.js +++ b/src/index.js @@ -35,6 +35,8 @@ import isDivisibleBy from './lib/isDivisibleBy'; import isHexColor from './lib/isHexColor'; +import isISRC from './lib/isISRC'; + import isMD5 from './lib/isMD5'; import isJSON from './lib/isJSON'; @@ -114,6 +116,7 @@ const validator = { isHexadecimal, isDivisibleBy, isHexColor, + isISRC, isMD5, isJSON, isEmpty, diff --git a/src/lib/isISRC.js b/src/lib/isISRC.js new file mode 100644 index 000000000..052f7657a --- /dev/null +++ b/src/lib/isISRC.js @@ -0,0 +1,9 @@ +import assertString from './util/assertString'; + +// see http://isrc.ifpi.org/en/isrc-standard/code-syntax +const isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/; + +export default function isISRC(str) { + assertString(str); + return isrc.test(str); +} diff --git a/test/validators.js b/test/validators.js index 1464aeafd..93d7ace75 100644 --- a/test/validators.js +++ b/test/validators.js @@ -1397,6 +1397,24 @@ describe('Validators', function () { }); }); + it('should validate ISRC code strings', function () { + test({ + validator: 'isISRC', + valid: [ + 'USAT29900609', + 'GBAYE6800011', + 'USRC15705223', + 'USCA29500702', + ], + invalid: [ + 'USAT2990060', + 'SRC15705223', + 'US-CA29500702', + 'USARC15705223', + ], + }); + }); + it('should validate md5 strings', function () { test({ validator: 'isMD5', diff --git a/validator.js b/validator.js index 51cba9e9f..2cde7830e 100644 --- a/validator.js +++ b/validator.js @@ -732,6 +732,14 @@ return hexcolor.test(str); } + // see http://isrc.ifpi.org/en/isrc-standard/code-syntax + var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/; + + function isISRC(str) { + assertString(str); + return isrc.test(str); + } + var md5 = /^[a-f0-9]{32}$/; function isMD5(str) { @@ -1353,6 +1361,7 @@ isHexadecimal: isHexadecimal, isDivisibleBy: isDivisibleBy, isHexColor: isHexColor, + isISRC: isISRC, isMD5: isMD5, isJSON: isJSON, isEmpty: isEmpty, diff --git a/validator.min.js b/validator.min.js index f8d4c42ec..305fa0d98 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)throw new TypeError("This library (validator.js) validates strings only")}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 o(t,r){return e(t),parseInt(t,r||10)}function n(t,r){return e(t),r?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t}function i(t,r){return e(t),t===r}function l(e){return"object"===("undefined"==typeof e?"undefined":de(e))&&null!==e?e="function"==typeof e.toString?e.toString():"[object Object]":(null===e||"undefined"==typeof e||isNaN(e)&&!e.length)&&(e=""),String(e)}function a(t,r){return e(t),t.indexOf(l(r))>=0}function u(t,r,o){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,o)),r.test(t)}function s(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];for(var r in t)"undefined"==typeof e[r]&&(e[r]=t[r]);return e}function c(t,r){e(t);var o=void 0,n=void 0;"object"===("undefined"==typeof r?"undefined":de(r))?(o=r.min||0,n=r.max):(o=arguments[1],n=arguments[2]);var i=encodeURI(t).split(/%..|./).length-1;return i>=o&&("undefined"==typeof n||i<=n)}function f(t,r){e(t),r=s(r,pe),r.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var o=t.split(".");if(r.require_tld){var n=o.pop();if(!o.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(e(t),r=String(r),!r)return p(t,4)||p(t,6);if("4"===r){if(!$e.test(t))return!1;var o=t.split(".").sort(function(e,t){return e-t});return o[3]<=255}if("6"===r){var n=t.split(":"),i=!1,l=p(n[n.length-1],4),a=l?7:8;if(n.length>a)return!1;if("::"===t)return!0;"::"===t.substr(0,2)?(n.shift(),n.shift(),i=!0):"::"===t.substr(t.length-2)&&(n.pop(),n.pop(),i=!0);for(var u=0;u0&&u=1:n.length===a}return!1}function h(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function g(e,t){for(var r=0;r=2083||/[\s<>]/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=s(r,ye);var o=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=t.split("#"),t=c.shift(),c=t.split("?"),t=c.shift(),c=t.split("://"),c.length>1){if(o=c.shift(),r.require_valid_protocol&&r.protocols.indexOf(o)===-1)return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(c[0]=t.substr(2))}if(t=c.join("://"),c=t.split("/"),t=c.shift(),""===t&&!r.require_host)return!0;if(c=t.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(we);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,r)||d&&p(d,6)||"localhost"===i)&&(i=i||d,!(r.host_whitelist&&!g(i,r.host_whitelist))&&(!r.host_blacklist||!g(i,r.host_blacklist))))}function _(t){return e(t),Ae.test(t)}function v(t){return e(t),["true","false","1","0"].indexOf(t)>=0}function F(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in be)return be[r].test(t);throw new Error("Invalid locale '"+r+"'")}function $(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";if(e(t),r in ke)return ke[r].test(t);throw new Error("Invalid locale '"+r+"'")}function x(t){return e(t),Ie.test(t)}function y(t){return e(t),t===t.toLowerCase()}function w(t){return e(t),t===t.toUpperCase()}function A(t){return e(t),Ce.test(t)}function b(t){return e(t),Re.test(t)}function k(t){return e(t),je.test(t)}function S(t){return e(t),Re.test(t)&&je.test(t)}function D(t){return e(t),Pe.test(t)}function E(t){return e(t),Ue.test(t)}function Z(t,r){e(t),r=r||{};var o=r.hasOwnProperty("allow_leading_zeroes")&&!r.allow_leading_zeroes?ze:Ne,n=!r.hasOwnProperty("min")||t>=r.min,i=!r.hasOwnProperty("max")||t<=r.max,l=!r.hasOwnProperty("lt")||tr.gt;return o.test(t)&&n&&i&&l&&a}function O(t,r){return e(t),r=r||{},""!==t&&"."!==t&&(Be.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)&&(!r.hasOwnProperty("lt")||tr.gt))}function I(t){return e(t),""!==t&&Le.test(t)}function C(t){return e(t),qe.test(t)}function R(t,o){return e(t),r(t)%parseInt(o,10)===0}function j(t){return e(t),Te.test(t)}function P(t){return e(t),He.test(t)}function U(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===("undefined"==typeof r?"undefined":de(r))}catch(e){}return!1}function z(t){return e(t),0===t.length}function N(t,r){e(t);var o=void 0,n=void 0;"object"===("undefined"==typeof r?"undefined":de(r))?(o=r.min||0,n=r.max):(o=arguments[1],n=arguments[2]);var i=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=t.length-i.length;return l>=o&&("undefined"==typeof n||l<=n)}function B(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";e(t);var o=Me[r];return o&&o.test(t)}function L(t){return e(t),C(t)&&24===t.length}function q(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var n=t(o),i=t(r);return!!(i&&n&&i>n)}function T(r){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(r);var n=t(o),i=t(r);return!!(i&&n&&i=0}return"object"===("undefined"==typeof r?"undefined":de(r))?r.hasOwnProperty(t):!(!r||"function"!=typeof r.indexOf)&&r.indexOf(t)>=0}function M(t){e(t);var r=t.replace(/[^0-9]+/g,"");if(!Ke.test(r))return!1;for(var o=0,n=void 0,i=void 0,l=void 0,a=r.length-1;a>=0;a--)n=r.substring(a,a+1),i=parseInt(n,10),l?(i*=2,o+=i>=10?i%10+1:i):o+=i,l=!l;return!(o%10!==0||!r)}function K(t){if(e(t),!We.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),o=0,n=void 0,i=void 0,l=!0,a=r.length-2;a>=0;a--)n=r.substring(a,a+1),i=parseInt(n,10),l?(i*=2,o+=i>=10?i+1:i):o+=i,l=!l;return parseInt(t.substr(t.length-1),10)===(1e4-o)%10}function W(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(e(t),r=String(r),!r)return W(t,10)||W(t,13);var o=t.replace(/[\s-]+/g,""),n=0,i=void 0;if("10"===r){if(!Ge.test(o))return!1;for(i=0;i<9;i++)n+=(i+1)*o.charAt(i);if(n+="X"===o.charAt(9)?100:10*o.charAt(9),n%11===0)return!!o}else if("13"===r){if(!Ye.test(o))return!1;for(i=0;i<12;i++)n+=Je[i%2]*o.charAt(i);if(o.charAt(12)-(10-n%10)%10===0)return!!o}return!1}function G(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var o=Qe;if(o=r.require_hyphen?o.replace("?",""):o,o=r.case_sensitive?new RegExp(o):new RegExp(o,"i"),!o.test(t))return!1;var n=t.replace("-",""),i=8,l=0,a=!0,u=!1,s=void 0;try{for(var c,f=n[Symbol.iterator]();!(a=(c=f.next()).done);a=!0){var d=c.value,p="X"===d.toUpperCase()?10:+d;l+=p*i,--i}}catch(e){u=!0,s=e}finally{try{!a&&f.return&&f.return()}finally{if(u)throw s}}return l%11===0}function Y(t,r){return e(t),r in Xe&&Xe[r].test(t)}function J(e){var t="(\\"+e.symbol.replace(/\./g,"\\.")+")"+(e.require_symbol?"":"?"),r="-?",o="[1-9]\\d*",n="[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*",i=["0",o,n],l="("+i.join("|")+")?",a="(\\"+e.decimal_separator+"\\d{2})?",u=l+a;return e.allow_negatives&&!e.parens_for_negatives&&(e.negative_sign_after_digits?u+=r:e.negative_sign_before_digits&&(u=r+u)),e.allow_negative_sign_placeholder?u="( (?!\\-))?"+u:e.allow_space_after_symbol?u=" ?"+u:e.allow_space_after_digits&&(u+="( (?!$))?"),e.symbol_after_digits?u+=t:u=t+u,e.allow_negatives&&(e.parens_for_negatives?u="(\\("+u+"\\)|"+u+")":e.negative_sign_before_digits||e.negative_sign_after_digits||(u=r+u)),new RegExp("^(?!-? )(?=.*\\d)"+u+"$")}function Q(t,r){return e(t),r=s(r,Ve),J(r).test(t)}function X(t){return e(t),et.test(t)}function V(t){e(t);var r=t.length;if(!r||r%4!==0||tt.test(t))return!1;var o=t.indexOf("=");return o===-1||o===r-1||o===r-2&&"="===t[r-1]}function ee(t){return e(t),rt.test(t)}function te(t,r){e(t);var o=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(o,"")}function re(t,r){e(t);for(var o=r?new RegExp("["+r+"]"):/\s/,n=t.length-1;n>=0&&o.test(t[n]);)n--;return n/g,">").replace(/\//g,"/").replace(/\\/g,"\").replace(/`/g,"`")}function ie(t){return e(t),t.replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(///g,"/").replace(/`/g,"`")}function le(t,r){return e(t),t.replace(new RegExp("["+r+"]+","g"),"")}function ae(t,r){e(t);var o=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return le(t,o)}function ue(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")}function se(t,r){e(t);for(var o=t.length-1;o>=0;o--)if(r.indexOf(t[o])===-1)return!1;return!0}function ce(e,t){if(t=s(t,ot),!d(e))return!1;var r=e.split("@"),o=r.pop(),n=r.join("@"),i=[n,o];if(i[1]=i[1].toLowerCase(),"gmail.com"===i[1]||"googlemail.com"===i[1]){if(t.gmail_remove_subaddress&&(i[0]=i[0].split("+")[0]),t.gmail_remove_dots&&(i[0]=i[0].replace(/\./g,"")),!i[0].length)return!1;(t.all_lowercase||t.gmail_lowercase)&&(i[0]=i[0].toLowerCase()),i[1]=t.gmail_convert_googlemaildotcom?"gmail.com":i[1]}else if(~nt.indexOf(i[1])){if(t.icloud_remove_subaddress&&(i[0]=i[0].split("+")[0]),!i[0].length)return!1;(t.all_lowercase||t.icloud_lowercase)&&(i[0]=i[0].toLowerCase())}else if(~it.indexOf(i[1])){if(t.outlookdotcom_remove_subaddress&&(i[0]=i[0].split("+")[0]),!i[0].length)return!1;(t.all_lowercase||t.outlookdotcom_lowercase)&&(i[0]=i[0].toLowerCase())}else if(~lt.indexOf(i[1])){if(t.yahoo_remove_subaddress){var l=i[0].split("-");i[0]=l.length>1?l.slice(0,-1).join("-"):l[0]}if(!i[0].length)return!1;(t.all_lowercase||t.yahoo_lowercase)&&(i[0]=i[0].toLowerCase())}else t.all_lowercase&&(i[0]=i[0].toLowerCase());return i.join("@")}for(var fe,de="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},pe=(function(){function e(e){this.value=e}function t(t){function r(e,t){return new Promise(function(r,n){var a={key:e,arg:t,resolve:r,reject:n,next:null};l?l=l.next=a:(i=l=a,o(e,t))})}function o(r,i){try{var l=t[r](i),a=l.value;a instanceof e?Promise.resolve(a.value).then(function(e){o("next",e)},function(e){o("throw",e)}):n(l.done?"return":"normal",l.value)}catch(e){n("throw",e)}}function n(e,t){switch(e){case"return":i.resolve({value:t,done:!0});break;case"throw":i.reject(t);break;default:i.resolve({value:t,done:!1})}i=i.next,i?o(i.key,i.arg):l=null}var i,l;this._invoke=r,"function"!=typeof t.return&&(this.return=void 0)}return"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)},{wrap:function(e){return function(){return new t(e.apply(this,arguments))}},await:function(t){return new e(t)}}}(),{require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1}),he={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},ge=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,me=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,_e=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,ve=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,Fe=/^([\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,$e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,xe=/^[0-9A-F]{1,4}$/i,ye={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},we=/^\[([^\]]+)\](?::([0-9]+))?$/,Ae=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,be={"en-US":/^[A-Z]+$/i,"cs-CZ":/^[A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},ke={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nl-NL":/^[0-9A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Se=["AU","GB","HK","IN","NZ","ZA","ZM"],De=0;De=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)void 0===t[o]&&(t[o]=e[o]);return t}function c(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":ht(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=encodeURI(e).split(/%..|./).length-1;return n>=r&&(void 0===i||n<=i)}function f(e,o){t(e),o=s(o,pt),o.allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));var r=e.split(".");if(o.require_tld){var i=r.pop();if(!r.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var n,l=0;l1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return h(e,4)||h(e,6);if("4"===o){if(!xt.test(e))return!1;return e.split(".").sort(function(t,e){return t-e})[3]<=255}if("6"===o){var r=e.split(":"),i=!1,n=h(r[r.length-1],4),l=n?7:8;if(r.length>l)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(r.shift(),r.shift(),i=!0):"::"===e.substr(e.length-2)&&(r.pop(),r.pop(),i=!0);for(var a=0;a0&&a=1:r.length===l}return!1}function p(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function g(t,e){for(var o=0;o2083||/[\s<>]/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;o=s(o,yt);var r=void 0,i=void 0,n=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&&-1===o.protocols.indexOf(r))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())&&!o.require_host)return!0;if(c=e.split("@"),c.length>1&&(i=c.shift(),i.indexOf(":")>=0&&i.split(":").length>2))return!1;l=c.join("@"),u=d=null;var p=l.match(wt);return p?(n="",d=p[1],u=p[2]||null):(c=l.split(":"),n=c.shift(),c.length&&(u=c.join(":"))),!(null!==u&&(a=parseInt(u,10),!/^[0-9]+$/.test(u)||a<=0||a>65535))&&(!!(h(n)||f(n,o)||d&&h(d,6)||"localhost"===n)&&(n=n||d,!(o.host_whitelist&&!g(n,o.host_whitelist))&&(!o.host_blacklist||!g(n,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 St)return St[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 y(e){return t(e),e===e.toUpperCase()}function w(e){return t(e),Rt.test(e)}function b(e){return t(e),jt.test(e)}function k(e){return t(e),Pt.test(e)}function S(e){return t(e),jt.test(e)&&Pt.test(e)}function D(e){return t(e),Ut.test(e)}function Z(e){return t(e),zt.test(e)}function E(e,o){t(e),o=o||{};var r=o.hasOwnProperty("allow_leading_zeroes")&&!o.allow_leading_zeroes?Nt:Bt,i=!o.hasOwnProperty("min")||e>=o.min,n=!o.hasOwnProperty("max")||e<=o.max,l=!o.hasOwnProperty("lt")||eo.gt;return r.test(e)&&i&&n&&l&&a}function O(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 I(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),Ht.test(e)}function P(e){return t(e),Mt.test(e)}function U(e){return t(e),Kt.test(e)}function z(e){t(e);try{var o=JSON.parse(e);return!!o&&"object"===(void 0===o?"undefined":ht(o))}catch(t){}return!1}function N(e){return t(e),0===e.length}function B(e,o){t(e);var r=void 0,i=void 0;"object"===(void 0===o?"undefined":ht(o))?(r=o.min||0,i=o.max):(r=arguments[1],i=arguments[2]);var n=e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],l=e.length-n.length;return l>=r&&(void 0===i||l<=i)}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 q(e){return t(e),C(e)&&24===e.length}function T(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n>i)}function H(o){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);t(o);var i=e(r),n=e(o);return!!(n&&i&&n=0}return"object"===(void 0===o?"undefined":ht(o))?o.hasOwnProperty(e):!(!o||"function"!=typeof o.indexOf)&&o.indexOf(e)>=0}function K(e){t(e);var o=e.replace(/[^0-9]+/g,"");if(!Gt.test(o))return!1;for(var r=0,i=void 0,n=void 0,l=void 0,a=o.length-1;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),l?(n*=2,r+=n>=10?n%10+1:n):r+=n,l=!l;return!(r%10!=0||!o)}function W(e){if(t(e),!Yt.test(e))return!1;for(var o=e.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),r=0,i=void 0,n=void 0,l=!0,a=o.length-2;a>=0;a--)i=o.substring(a,a+1),n=parseInt(i,10),l?(n*=2,r+=n>=10?n+1:n):r+=n,l=!l;return parseInt(e.substr(e.length-1),10)===(1e4-r)%10}function G(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t(e),!(o=String(o)))return G(e,10)||G(e,13);var r=e.replace(/[\s-]+/g,""),i=0,n=void 0;if("10"===o){if(!Jt.test(r))return!1;for(n=0;n<9;n++)i+=(n+1)*r.charAt(n);if("X"===r.charAt(9)?i+=100:i+=10*r.charAt(9),i%11==0)return!!r}else if("13"===o){if(!Qt.test(r))return!1;for(n=0;n<12;n++)i+=Xt[n%2]*r.charAt(n);if(r.charAt(12)-(10-i%10)%10==0)return!!r}return!1}function Y(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t(e);var r=Vt;if(r=o.require_hyphen?r.replace("?",""):r,r=o.case_sensitive?new RegExp(r):new RegExp(r,"i"),!r.test(e))return!1;var i=e.replace("-",""),n=8,l=0,a=!0,u=!1,s=void 0;try{for(var c,f=i[Symbol.iterator]();!(a=(c=f.next()).done);a=!0){var d=c.value;l+=("X"===d.toUpperCase()?10:+d)*n,--n}}catch(t){u=!0,s=t}finally{try{!a&&f.return&&f.return()}finally{if(u)throw s}}return l%11==0}function J(e,o){return t(e),o in te&&te[o].test(e)}function Q(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),o="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",r=["0","[1-9]\\d*",o],i="("+r.join("|")+")?",n="(\\"+t.decimal_separator+"\\d{2})?",l=i+n;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?l+="-?":t.negative_sign_before_digits&&(l="-?"+l)),t.allow_negative_sign_placeholder?l="( (?!\\-))?"+l:t.allow_space_after_symbol?l=" ?"+l:t.allow_space_after_digits&&(l+="( (?!$))?"),t.symbol_after_digits?l+=e:l=e+l,t.allow_negatives&&(t.parens_for_negatives?l="(\\("+l+"\\)|"+l+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(l="-?"+l)),new RegExp("^(?!-? )(?=.*\\d)"+l+"$")}function X(e,o){return t(e),o=s(o,ee),Q(o).test(e)}function V(e){return t(e),oe.test(e)}function tt(e){t(e);var o=e.length;if(!o||o%4!=0||re.test(e))return!1;var r=e.indexOf("=");return-1===r||r===o-1||r===o-2&&"="===e[o-1]}function et(e){return t(e),ie.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/,i=e.length-1;i>=0&&r.test(e[i]);)i--;return i/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){return t(e),at(e,o?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F")}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(-1===o.indexOf(e[r]))return!1;return!0}function ft(t,e){if(e=s(e,ne),!d(t))return!1;var o=t.split("@"),r=o.pop(),i=o.join("@"),n=[i,r];if(n[1]=n[1].toLowerCase(),"gmail.com"===n[1]||"googlemail.com"===n[1]){if(e.gmail_remove_subaddress&&(n[0]=n[0].split("+")[0]),e.gmail_remove_dots&&(n[0]=n[0].replace(/\./g,"")),!n[0].length)return!1;(e.all_lowercase||e.gmail_lowercase)&&(n[0]=n[0].toLowerCase()),n[1]=e.gmail_convert_googlemaildotcom?"gmail.com":n[1]}else if(~le.indexOf(n[1])){if(e.icloud_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.icloud_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~ae.indexOf(n[1])){if(e.outlookdotcom_remove_subaddress&&(n[0]=n[0].split("+")[0]),!n[0].length)return!1;(e.all_lowercase||e.outlookdotcom_lowercase)&&(n[0]=n[0].toLowerCase())}else if(~ue.indexOf(n[1])){if(e.yahoo_remove_subaddress){var l=n[0].split("-");n[0]=l.length>1?l.slice(0,-1).join("-"):l[0]}if(!n[0].length)return!1;(e.all_lowercase||e.yahoo_lowercase)&&(n[0]=n[0].toLowerCase())}else e.all_lowercase&&(n[0]=n[0].toLowerCase());return n.join("@")}for(var dt,ht="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},pt=(function(){function t(t){this.value=t}function e(e){function o(t,e){return new Promise(function(o,i){var a={key:t,arg:e,resolve:o,reject:i,next:null};l?l=l.next=a:(n=l=a,r(t,e))})}function r(o,n){try{var l=e[o](n),a=l.value;a instanceof t?Promise.resolve(a.value).then(function(t){r("next",t)},function(t){r("throw",t)}):i(l.done?"return":"normal",l.value)}catch(t){i("throw",t)}}function i(t,e){switch(t){case"return":n.resolve({value:e,done:!0});break;case"throw":n.reject(e);break;default:n.resolve({value:e,done:!1})}n=n.next,n?r(n.key,n.arg):l=null}var n,l;this._invoke=o,"function"!=typeof e.return&&(this.return=void 0)}"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)}}(),{require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1}),gt={allow_display_name:!1,require_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,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},wt=/^\[([^\]]+)\](?::([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,"da-DK":/^[A-ZÆØÅ]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"hu-HU":/^[A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁ]+$/i,"sr-RS@latin":/^[A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},St={"en-US":/^[0-9A-Z]+$/i,"cs-CZ":/^[0-9A-ZÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ]+$/i,"da-DK":/^[0-9A-ZÆØÅ]$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[0-9A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"hu-HU":/^[0-9A-ZÁÉÍÓÖŐÚÜŰ]+$/i,"nl-NL":/^[0-9A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[0-9А-ЯЁ]+$/i,"sr-RS@latin":/^[0-9A-ZČĆŽŠĐ]+$/i,"sr-RS":/^[0-9А-ЯЂЈЉЊЋЏ]+$/i,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,"uk-UA":/^[0-9А-ЩЬЮЯЄIЇҐ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Dt=["AU","GB","HK","IN","NZ","ZA","ZM"],Zt=0;Zt