From 2cf66ac8497d52efcda1548b15a7ffff128c1536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mahmut=20Kerem=20Gu=CC=88c=CC=A7?= Date: Sat, 27 Feb 2016 03:42:05 +0200 Subject: [PATCH] Turkish locales for isAlpha, isAlphaNumeric and isMobilePhone --- README.md | 6 +++--- lib/alpha.js | 2 ++ lib/isMobilePhone.js | 1 + src/lib/alpha.js | 2 ++ src/lib/isMobilePhone.js | 1 + test/validators.js | 34 ++++++++++++++++++++++++++++++++++ validator.js | 3 +++ validator.min.js | 2 +- 8 files changed, 47 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 052dbe27a..11421e222 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ Passing anything other than a string is an error. - **contains(str, seed)** - check if the string contains the seed. - **equals(str, comparison)** - check if the string matches the comparison. - **isAfter(str [, date])** - check if the string is a date that's after the specified date (defaults to now). -- **isAlpha(str [, locale])** - check if the string contains only letters (a-zA-Z). Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QM', 'ar-QA', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'en-US', 'de-DE', 'es-ES', 'fr-FR', 'nl-NL', 'pl-PL', 'pt-PT', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-ZA', 'en-ZM', 'ru-RU']`) and defaults to `en-US`. -- **isAlphanumeric(str [, locale])** - check if the string contains only letters and numbers. Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QM', 'ar-QA', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'en-US', 'de-DE', 'es-ES', 'fr-FR', 'nl-NL', 'pl-PL', 'pt-PT', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-ZA', 'en-ZM', 'ru-RU']`) and defaults to `en-US`. +- **isAlpha(str [, locale])** - check if the string contains only letters (a-zA-Z). Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'tr-TR']`) and defaults to `en-US`. +- **isAlphanumeric(str [, locale])** - check if the string contains only letters and numbers. Locale is one of `['ar', 'ar-AE', 'ar-BH', 'ar-DZ', 'ar-EG', 'ar-IQ', 'ar-JO', 'ar-KW', 'ar-LB', 'ar-LY', 'ar-MA', 'ar-QA', 'ar-QM', 'ar-SA', 'ar-SD', 'ar-SY', 'ar-TN', 'ar-YE', 'de-DE', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fr-FR', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'tr-TR']`) and defaults to `en-US`. - **isAscii(str)** - check if the string contains ASCII chars only. - **isBase64(str)** - check if a string is base64 encoded. - **isBefore(str [, date])** - check if the string is a date that's before the specified date. @@ -84,7 +84,7 @@ Passing anything other than a string is an error. - **isLength(str, options)** - check if the string's length falls in a range. `options` is an object which defaults to `{min:0, max: undefined}`. Note: this function takes into account surrogate pairs. - **isLowercase(str)** - check if the string is lowercase. - **isMACAddress(str)** - check if the string is a MAC address. -- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-SY', 'zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK', 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN', 'en-NZ', 'en-IN', 'es-ES', 'de-DE', 'fi-FI', 'ms-MY']`). +- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['ar-SY', 'de-DE', 'el-GR', 'en-AU', 'en-GB', 'en-HK', 'en-IN', 'en-NZ', 'en-US', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'ms-MY', 'nb-NO', 'nn-NO', 'pt-PT', 'ru-RU', 'tr-TR', 'vi-VN', 'zh-CN', 'zh-TW']`). - **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. - **isMultibyte(str)** - check if the string contains one or more multibyte chars. - **isNull(str)** - check if the string is null (has a length of zero). diff --git a/lib/alpha.js b/lib/alpha.js index 261769c5d..1a0a5d419 100644 --- a/lib/alpha.js +++ b/lib/alpha.js @@ -12,6 +12,7 @@ var alpha = exports.alpha = { 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[А-ЯЁа-яё]+$/i, + 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/ }; @@ -24,6 +25,7 @@ var alphanumeric = exports.alphanumeric = { 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[0-9А-ЯЁа-яё]+$/i, + 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/ }; diff --git a/lib/isMobilePhone.js b/lib/isMobilePhone.js index 7a65c0d0f..6c0bef18a 100644 --- a/lib/isMobilePhone.js +++ b/lib/isMobilePhone.js @@ -33,6 +33,7 @@ var phones = { 'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, + 'tr-TR': /^(\+?90|0)?5\d{9}$/, 'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/, 'zh-CN': /^(\+?0?86\-?)?((13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7})$/, 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ diff --git a/src/lib/alpha.js b/src/lib/alpha.js index 26f875d28..934667313 100644 --- a/src/lib/alpha.js +++ b/src/lib/alpha.js @@ -7,6 +7,7 @@ export const alpha = { 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[А-ЯЁа-яё]+$/i, + 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, }; @@ -19,6 +20,7 @@ export const alphanumeric = { 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[0-9А-ЯЁа-яё]+$/i, + 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/, }; diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 1761a33d0..c96af2f8e 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -22,6 +22,7 @@ const phones = { 'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, + 'tr-TR': /^(\+?90|0)?5\d{9}$/, 'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/, 'zh-CN': /^(\+?0?86\-?)?((13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7})$/, 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/, diff --git a/test/validators.js b/test/validators.js index 191f25531..5c1f78897 100644 --- a/test/validators.js +++ b/test/validators.js @@ -622,6 +622,25 @@ describe('Validators', function () { }); }); + it('should validate turkish alpha strings', function () { + test({ + validator: 'isAlpha', + args: ['tr-TR'], + valid: [ + 'AİıÖöÇ窺ĞğÜüZ', + ], + invalid: [ + '0AİıÖöÇ窺ĞğÜüZ1', + ' AİıÖöÇ窺ĞğÜüZ ', + 'abc1', + ' foo ', + '', + 'ÄBC', + 'Heiß', + ], + }); + }); + it('should validate alphanumeric strings', function () { test({ validator: 'isAlphanumeric', @@ -722,6 +741,21 @@ describe('Validators', function () { }); }); + it('should validate turkish alphanumeric strings', function () { + test({ + validator: 'isAlphanumeric', + args: ['tr-TR'], + valid: [ + 'AİıÖöÇ窺ĞğÜüZ123', + ], + invalid: [ + 'AİıÖöÇ窺ĞğÜüZ ', + 'foo!!', + 'ÄBC', + ], + }); + }); + it('should error on invalid locale', function () { try { validator.isAlphanumeric('abc123', 'in-INVALID'); diff --git a/validator.js b/validator.js index 30a9f0b64..45b9e28d6 100644 --- a/validator.js +++ b/validator.js @@ -390,6 +390,7 @@ 'pl-PL': /^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[А-ЯЁа-яё]+$/i, + 'tr-TR': /^[A-ZÇĞİıÖŞÜ]+$/i, ar: /^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/ }; @@ -402,6 +403,7 @@ 'pl-PL': /^[0-9A-ZĄĆĘŚŁŃÓŻŹ]+$/i, 'pt-PT': /^[0-9A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i, 'ru-RU': /^[0-9А-ЯЁа-яё]+$/i, + 'tr-TR': /^[0-9A-ZÇĞİıÖŞÜ]+$/i, ar: /^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/ }; @@ -861,6 +863,7 @@ 'pt-BR': /^(\+?55|0)\-?[1-9]{2}\-?[2-9]{1}\d{3,4}\-?\d{4}$/, 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 'ru-RU': /^(\+?7|8)?9\d{9}$/, + 'tr-TR': /^(\+?90|0)?5\d{9}$/, 'vi-VN': /^(\+?84|0)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/, 'zh-CN': /^(\+?0?86\-?)?((13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7})$/, 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ diff --git a/validator.min.js b/validator.min.js index d662e8c65..8633221ed 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 n(t,r){return e(t),parseInt(t,r||10)}function i(t,r){return e(t),r?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t}function o(t,r){return e(t),t===r}function u(e){return"object"===("undefined"==typeof e?"undefined":ae["typeof"](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(u(r))>=0}function s(t,r,n){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,n)),r.test(t)}function l(){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 f(t,r){e(t);var n=void 0,i=void 0;"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?(n=r.min||0,i=r.max):(n=arguments[1],i=arguments[2]);var o=encodeURI(t).split(/%..|./).length-1;return o>=n&&("undefined"==typeof i||i>=o)}function d(t,r){e(t),r=l(r,le),r.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var n=t.split(".");if(r.require_tld){var i=n.pop();if(!n.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var o,u=0;u=0)return!1;o=o.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if("-"===o[0]||"-"===o[o.length-1])return!1}return!0}function c(t,r){if(e(t),r=l(r,fe),r.allow_display_name){var n=t.match(de);n&&(t=n[1])}var i=t.split("@"),o=i.pop(),u=i.join("@"),a=o.toLowerCase();if(("gmail.com"===a||"googlemail.com"===a)&&(u=u.replace(/\./g,"").toLowerCase()),!f(u,{max:64})||!f(o,{max:256}))return!1;if(!d(o,{require_tld:r.require_tld}))return!1;if('"'===u[0])return u=u.slice(1,u.length-1),r.allow_utf8_local_part?Fe.test(u):ge.test(u);for(var s=r.allow_utf8_local_part?pe:ce,c=u.split("."),g=0;ga)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 p(t,r){if(e(t),!t||t.length>=2083||/\s/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=l(r,me);var n=void 0,i=void 0,o=void 0,u=void 0,a=void 0,s=void 0,f=void 0;if(f=t.split("://"),f.length>1){if(n=f.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(n))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(f[0]=t.substr(2))}return t=f.join("://"),f=t.split("#"),t=f.shift(),f=t.split("?"),t=f.shift(),f=t.split("/"),t=f.shift(),f=t.split("@"),f.length>1&&(i=f.shift(),i.indexOf(":")>=0&&i.split(":").length>2)?!1:(u=f.join("@"),f=u.split(":"),o=f.shift(),f.length&&(s=f.join(":"),a=parseInt(s,10),!/^[0-9]+$/.test(s)||0>=a||a>65535)?!1:g(o)||d(o,r)||"localhost"===o?r.host_whitelist&&-1===r.host_whitelist.indexOf(o)?!1:r.host_blacklist&&-1!==r.host_blacklist.indexOf(o)?!1:!0:!1)}function F(t){return e(t),he.test(t)}function v(t){return e(t),["true","false","1","0"].indexOf(t)>=0}function _(t){var r=arguments.length<=1||void 0===arguments[1]?"en-US":arguments[1];if(e(t),r in xe)return xe[r].test(t);throw new Error("Invalid locale '"+r+"'")}function m(t){var r=arguments.length<=1||void 0===arguments[1]?"en-US":arguments[1];if(e(t),r in $e)return $e[r].test(t);throw new Error("Invalid locale '"+r+"'")}function h(t){return e(t),be.test(t)}function x(t){return e(t),t===t.toLowerCase()}function $(t){return e(t),t===t.toUpperCase()}function A(t){return e(t),De.test(t)}function w(t){return e(t),Ee.test(t)}function y(t){return e(t),Se.test(t)}function b(t){return e(t),Ee.test(t)&&Se.test(t)}function D(t){return e(t),Oe.test(t)}function E(t){return e(t),Ie.test(t)}function S(t,r){return e(t),r=r||{},Ze.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)}function O(t,r){return e(t),r=r||{},""===t||"."===t?!1:Ce.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)}function I(t){return e(t),""!==t&&Ne.test(t)}function Z(t){return e(t),je.test(t)}function C(t,n){return e(t),r(t)%parseInt(n,10)===0}function N(t){return e(t),Le.test(t)}function j(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))}catch(n){}return!1}function L(t){return e(t),0===t.length}function R(t,r){e(t);var n=void 0,i=void 0;"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?(n=r.min||0,i=r.max):(n=arguments[1],i=arguments[2]);var o=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],u=t.length-o.length;return u>=n&&("undefined"==typeof i||i>=u)}function U(t){var r=arguments.length<=1||void 0===arguments[1]?"all":arguments[1];e(t);var n=Re[r];return n&&n.test(t)}function B(t){return e(t),Z(t)&&24===t.length}function z(t){return e(t),Ue.test(t)}function q(e){var t=e.match(Ue),r=void 0,n=void 0,i=void 0,o=void 0;if(t){if(r=t[21],!r)return t[12]?null:0;if("z"===r||"Z"===r)return 0;n=t[22],-1!==r.indexOf(":")?(i=parseInt(t[23],10),o=parseInt(t[24],10)):(i=0,o=parseInt(t[23],10))}else{if(e=e.toLowerCase(),r=e.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!r)return-1!==e.indexOf("gmt")?0:null;n=r[1];var u=r[2];3===u.length&&(u="0"+u),u.length<=2?(i=0,o=parseInt(u,10)):(i=parseInt(u.slice(0,2),10),o=parseInt(u.slice(2,4),10))}return(60*i+o)*("-"===n?1:-1)}function P(t){e(t);var r=new Date(Date.parse(t));if(isNaN(r))return!1;var n=q(t);if(null!==n){var i=r.getTimezoneOffset()-n;r=new Date(r.getTime()+6e4*i)}var o=String(r.getDate()),u=void 0,a=void 0,s=void 0;return(a=t.match(/(^|[^:\d])[23]\d([^:\d]|$)/g))?(u=a.map(function(e){return e.match(/\d+/g)[0]}).join("/"),s=String(r.getFullYear()).slice(-2),u===o||u===s?!0:u===""+o/s||u===""+s/o?!0:!1):!0}function T(r){var n=arguments.length<=1||void 0===arguments[1]?String(new Date):arguments[1];e(r);var i=t(n),o=t(r);return!!(o&&i&&o>i)}function M(r){var n=arguments.length<=1||void 0===arguments[1]?String(new Date):arguments[1];e(r);var i=t(n),o=t(r);return!!(o&&i&&i>o)}function W(t,r){e(t);var n=void 0;if("[object Array]"===Object.prototype.toString.call(r)){var i=[];for(n in r)({}).hasOwnProperty.call(r,n)&&(i[n]=u(r[n]));return i.indexOf(t)>=0}return"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?r.hasOwnProperty(t):r&&"function"==typeof r.indexOf?r.indexOf(t)>=0:!1}function H(t){e(t);var r=t.replace(/[^0-9]+/g,"");if(!Be.test(r))return!1;for(var n=0,i=void 0,o=void 0,u=void 0,a=r.length-1;a>=0;a--)i=r.substring(a,a+1),o=parseInt(i,10),u?(o*=2,n+=o>=10?o%10+1:o):n+=o,u=!u;return!!(n%10===0?r:!1)}function Y(t){if(e(t),!ze.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),n=0,i=void 0,o=void 0,u=!0,a=r.length-2;a>=0;a--)i=r.substring(a,a+1),o=parseInt(i,10),u?(o*=2,n+=o>=10?o+1:o):n+=o,u=!u;return parseInt(t.substr(t.length-1),10)===(1e4-n)%10}function G(t){var r=arguments.length<=1||void 0===arguments[1]?"":arguments[1];if(e(t),r=String(r),!r)return G(t,10)||G(t,13);var n=t.replace(/[\s-]+/g,""),i=0,o=void 0;if("10"===r){if(!qe.test(n))return!1;for(o=0;9>o;o++)i+=(o+1)*n.charAt(o);if(i+="X"===n.charAt(9)?100:10*n.charAt(9),i%11===0)return!!n}else if("13"===r){if(!Pe.test(n))return!1;for(o=0;12>o;o++)i+=Te[o%2]*n.charAt(o);if(n.charAt(12)-(10-i%10)%10===0)return!!n}return!1}function Q(t,r){return e(t),r in Me?Me[r].test(t):!1}function k(e){var t="(\\"+e.symbol.replace(/\./g,"\\.")+")"+(e.require_symbol?"":"?"),r="-?",n="[1-9]\\d*",i="[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*",o=["0",n,i],u="("+o.join("|")+")?",a="(\\"+e.decimal_separator+"\\d{2})?",s=u+a;return e.allow_negatives&&!e.parens_for_negatives&&(e.negative_sign_after_digits?s+=r:e.negative_sign_before_digits&&(s=r+s)),e.allow_negative_sign_placeholder?s="( (?!\\-))?"+s:e.allow_space_after_symbol?s=" ?"+s:e.allow_space_after_digits&&(s+="( (?!$))?"),e.symbol_after_digits?s+=t:s=t+s,e.allow_negatives&&(e.parens_for_negatives?s="(\\("+s+"\\)|"+s+")":e.negative_sign_before_digits||e.negative_sign_after_digits||(s=r+s)),new RegExp("^(?!-? )(?=.*\\d)"+s+"$")}function J(t,r){return e(t),r=l(r,We),k(r).test(t)}function K(t){e(t);var r=t.length;if(!r||r%4!==0||He.test(t))return!1;var n=t.indexOf("=");return-1===n||n===r-1||n===r-2&&"="===t[r-1]}function V(t,r){e(t);var n=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(n,"")}function X(t,r){e(t);var n=r?new RegExp("["+r+"]+$","g"):/\s+$/g;return t.replace(n,"")}function ee(t,r){e(t);var n=r?new RegExp("^["+r+"]+|["+r+"]+$","g"):/^\s+|\s+$/g;return t.replace(n,"")}function te(t){return e(t),t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\//g,"/").replace(/\`/g,"`")}function re(t,r){return e(t),t.replace(new RegExp("["+r+"]+","g"),"")}function ne(t,r){e(t);var n=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return re(t,n)}function ie(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")}function oe(t,r){e(t);for(var n=t.length-1;n>=0;n--)if(-1===r.indexOf(t[n]))return!1;return!0}function ue(e,t){if(t=l(t,Ye),!c(e))return!1;var r=e.split("@",2);if(r[1]=r[1].toLowerCase(),"gmail.com"===r[1]||"googlemail.com"===r[1]){if(t.remove_extension&&(r[0]=r[0].split("+")[0]),t.remove_dots&&(r[0]=r[0].replace(/\./g,"")),!r[0].length)return!1;r[0]=r[0].toLowerCase(),r[1]="gmail.com"}else t.lowercase&&(r[0]=r[0].toLowerCase());return r.join("@")}var ae={};ae["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};for(var se,le={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},fe={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},de=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,ce=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,ge=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,pe=/^[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,ve=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,_e=/^[0-9A-F]{1,4}$/i,me={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},he=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,xe={"en-US":/^[A-Z]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁа-яё]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},$e={"en-US":/^[0-9A-Z]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[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,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Ae=["AU","GB","HK","IN","NZ","ZA","ZM"],we=0;we=0}function s(t,r,n){return e(t),"[object RegExp]"!==Object.prototype.toString.call(r)&&(r=new RegExp(r,n)),r.test(t)}function l(){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 f(t,r){e(t);var n=void 0,i=void 0;"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?(n=r.min||0,i=r.max):(n=arguments[1],i=arguments[2]);var o=encodeURI(t).split(/%..|./).length-1;return o>=n&&("undefined"==typeof i||i>=o)}function d(t,r){e(t),r=l(r,le),r.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var n=t.split(".");if(r.require_tld){var i=n.pop();if(!n.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var o,u=0;u=0)return!1;o=o.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if("-"===o[0]||"-"===o[o.length-1])return!1}return!0}function c(t,r){if(e(t),r=l(r,fe),r.allow_display_name){var n=t.match(de);n&&(t=n[1])}var i=t.split("@"),o=i.pop(),u=i.join("@"),a=o.toLowerCase();if("gmail.com"!==a&&"googlemail.com"!==a||(u=u.replace(/\./g,"").toLowerCase()),!f(u,{max:64})||!f(o,{max:256}))return!1;if(!d(o,{require_tld:r.require_tld}))return!1;if('"'===u[0])return u=u.slice(1,u.length-1),r.allow_utf8_local_part?Fe.test(u):pe.test(u);for(var s=r.allow_utf8_local_part?ge:ce,c=u.split("."),p=0;pa)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 g(t,r){if(e(t),!t||t.length>=2083||/\s/.test(t))return!1;if(0===t.indexOf("mailto:"))return!1;r=l(r,he);var n=void 0,i=void 0,o=void 0,u=void 0,a=void 0,s=void 0,f=void 0;if(f=t.split("://"),f.length>1){if(n=f.shift(),r.require_valid_protocol&&-1===r.protocols.indexOf(n))return!1}else{if(r.require_protocol)return!1;r.allow_protocol_relative_urls&&"//"===t.substr(0,2)&&(f[0]=t.substr(2))}return t=f.join("://"),f=t.split("#"),t=f.shift(),f=t.split("?"),t=f.shift(),f=t.split("/"),t=f.shift(),f=t.split("@"),f.length>1&&(i=f.shift(),i.indexOf(":")>=0&&i.split(":").length>2)?!1:(u=f.join("@"),f=u.split(":"),o=f.shift(),f.length&&(s=f.join(":"),a=parseInt(s,10),!/^[0-9]+$/.test(s)||0>=a||a>65535)?!1:p(o)||d(o,r)||"localhost"===o?r.host_whitelist&&-1===r.host_whitelist.indexOf(o)?!1:!r.host_blacklist||-1===r.host_blacklist.indexOf(o):!1)}function F(t){return e(t),xe.test(t)}function v(t){return e(t),["true","false","1","0"].indexOf(t)>=0}function _(t){var r=arguments.length<=1||void 0===arguments[1]?"en-US":arguments[1];if(e(t),r in $e)return $e[r].test(t);throw new Error("Invalid locale '"+r+"'")}function h(t){var r=arguments.length<=1||void 0===arguments[1]?"en-US":arguments[1];if(e(t),r in Ae)return Ae[r].test(t);throw new Error("Invalid locale '"+r+"'")}function x(t){return e(t),be.test(t)}function $(t){return e(t),t===t.toLowerCase()}function A(t){return e(t),t===t.toUpperCase()}function m(t){return e(t),De.test(t)}function w(t){return e(t),Ee.test(t)}function y(t){return e(t),Se.test(t)}function b(t){return e(t),Ee.test(t)&&Se.test(t)}function D(t){return e(t),Oe.test(t)}function E(t){return e(t),Ze.test(t)}function S(t,r){return e(t),r=r||{},Ie.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)}function O(t,r){return e(t),r=r||{},""===t||"."===t?!1:Ce.test(t)&&(!r.hasOwnProperty("min")||t>=r.min)&&(!r.hasOwnProperty("max")||t<=r.max)}function Z(t){return e(t),""!==t&&Ne.test(t)}function I(t){return e(t),Re.test(t)}function C(t,n){return e(t),r(t)%parseInt(n,10)===0}function N(t){return e(t),je.test(t)}function R(t){e(t);try{var r=JSON.parse(t);return!!r&&"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))}catch(n){}return!1}function j(t){return e(t),0===t.length}function L(t,r){e(t);var n=void 0,i=void 0;"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?(n=r.min||0,i=r.max):(n=arguments[1],i=arguments[2]);var o=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],u=t.length-o.length;return u>=n&&("undefined"==typeof i||i>=u)}function U(t){var r=arguments.length<=1||void 0===arguments[1]?"all":arguments[1];e(t);var n=Le[r];return n&&n.test(t)}function B(t){return e(t),I(t)&&24===t.length}function z(t){return e(t),Ue.test(t)}function q(e){var t=e.match(Ue),r=void 0,n=void 0,i=void 0,o=void 0;if(t){if(r=t[21],!r)return t[12]?null:0;if("z"===r||"Z"===r)return 0;n=t[22],-1!==r.indexOf(":")?(i=parseInt(t[23],10),o=parseInt(t[24],10)):(i=0,o=parseInt(t[23],10))}else{if(e=e.toLowerCase(),r=e.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!r)return-1!==e.indexOf("gmt")?0:null;n=r[1];var u=r[2];3===u.length&&(u="0"+u),u.length<=2?(i=0,o=parseInt(u,10)):(i=parseInt(u.slice(0,2),10),o=parseInt(u.slice(2,4),10))}return(60*i+o)*("-"===n?1:-1)}function P(t){e(t);var r=new Date(Date.parse(t));if(isNaN(r))return!1;var n=q(t);if(null!==n){var i=r.getTimezoneOffset()-n;r=new Date(r.getTime()+6e4*i)}var o=String(r.getDate()),u=void 0,a=void 0,s=void 0;return(a=t.match(/(^|[^:\d])[23]\d([^:\d]|$)/g))?(u=a.map(function(e){return e.match(/\d+/g)[0]}).join("/"),s=String(r.getFullYear()).slice(-2),u===o||u===s?!0:u===""+o/s||u===""+s/o):!0}function T(r){var n=arguments.length<=1||void 0===arguments[1]?String(new Date):arguments[1];e(r);var i=t(n),o=t(r);return!!(o&&i&&o>i)}function M(r){var n=arguments.length<=1||void 0===arguments[1]?String(new Date):arguments[1];e(r);var i=t(n),o=t(r);return!!(o&&i&&i>o)}function W(t,r){e(t);var n=void 0;if("[object Array]"===Object.prototype.toString.call(r)){var i=[];for(n in r)({}).hasOwnProperty.call(r,n)&&(i[n]=u(r[n]));return i.indexOf(t)>=0}return"object"===("undefined"==typeof r?"undefined":ae["typeof"](r))?r.hasOwnProperty(t):r&&"function"==typeof r.indexOf?r.indexOf(t)>=0:!1}function H(t){e(t);var r=t.replace(/[^0-9]+/g,"");if(!Be.test(r))return!1;for(var n=0,i=void 0,o=void 0,u=void 0,a=r.length-1;a>=0;a--)i=r.substring(a,a+1),o=parseInt(i,10),u?(o*=2,n+=o>=10?o%10+1:o):n+=o,u=!u;return!!(n%10===0?r:!1)}function Y(t){if(e(t),!ze.test(t))return!1;for(var r=t.replace(/[A-Z]/g,function(e){return parseInt(e,36)}),n=0,i=void 0,o=void 0,u=!0,a=r.length-2;a>=0;a--)i=r.substring(a,a+1),o=parseInt(i,10),u?(o*=2,n+=o>=10?o+1:o):n+=o,u=!u;return parseInt(t.substr(t.length-1),10)===(1e4-n)%10}function G(t){var r=arguments.length<=1||void 0===arguments[1]?"":arguments[1];if(e(t),r=String(r),!r)return G(t,10)||G(t,13);var n=t.replace(/[\s-]+/g,""),i=0,o=void 0;if("10"===r){if(!qe.test(n))return!1;for(o=0;9>o;o++)i+=(o+1)*n.charAt(o);if(i+="X"===n.charAt(9)?100:10*n.charAt(9),i%11===0)return!!n}else if("13"===r){if(!Pe.test(n))return!1;for(o=0;12>o;o++)i+=Te[o%2]*n.charAt(o);if(n.charAt(12)-(10-i%10)%10===0)return!!n}return!1}function Q(t,r){return e(t),r in Me?Me[r].test(t):!1}function k(e){var t="(\\"+e.symbol.replace(/\./g,"\\.")+")"+(e.require_symbol?"":"?"),r="-?",n="[1-9]\\d*",i="[1-9]\\d{0,2}(\\"+e.thousands_separator+"\\d{3})*",o=["0",n,i],u="("+o.join("|")+")?",a="(\\"+e.decimal_separator+"\\d{2})?",s=u+a;return e.allow_negatives&&!e.parens_for_negatives&&(e.negative_sign_after_digits?s+=r:e.negative_sign_before_digits&&(s=r+s)),e.allow_negative_sign_placeholder?s="( (?!\\-))?"+s:e.allow_space_after_symbol?s=" ?"+s:e.allow_space_after_digits&&(s+="( (?!$))?"),e.symbol_after_digits?s+=t:s=t+s,e.allow_negatives&&(e.parens_for_negatives?s="(\\("+s+"\\)|"+s+")":e.negative_sign_before_digits||e.negative_sign_after_digits||(s=r+s)),new RegExp("^(?!-? )(?=.*\\d)"+s+"$")}function J(t,r){return e(t),r=l(r,We),k(r).test(t)}function K(t){e(t);var r=t.length;if(!r||r%4!==0||He.test(t))return!1;var n=t.indexOf("=");return-1===n||n===r-1||n===r-2&&"="===t[r-1]}function V(t,r){e(t);var n=r?new RegExp("^["+r+"]+","g"):/^\s+/g;return t.replace(n,"")}function X(t,r){e(t);var n=r?new RegExp("["+r+"]+$","g"):/\s+$/g;return t.replace(n,"")}function ee(t,r){e(t);var n=r?new RegExp("^["+r+"]+|["+r+"]+$","g"):/^\s+|\s+$/g;return t.replace(n,"")}function te(t){return e(t),t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">").replace(/\//g,"/").replace(/\`/g,"`")}function re(t,r){return e(t),t.replace(new RegExp("["+r+"]+","g"),"")}function ne(t,r){e(t);var n=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return re(t,n)}function ie(t,r){return e(t),t.replace(new RegExp("[^"+r+"]+","g"),"")}function oe(t,r){e(t);for(var n=t.length-1;n>=0;n--)if(-1===r.indexOf(t[n]))return!1;return!0}function ue(e,t){if(t=l(t,Ye),!c(e))return!1;var r=e.split("@",2);if(r[1]=r[1].toLowerCase(),"gmail.com"===r[1]||"googlemail.com"===r[1]){if(t.remove_extension&&(r[0]=r[0].split("+")[0]),t.remove_dots&&(r[0]=r[0].replace(/\./g,"")),!r[0].length)return!1;r[0]=r[0].toLowerCase(),r[1]="gmail.com"}else t.lowercase&&(r[0]=r[0].toLowerCase());return r.join("@")}var ae={};ae["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};for(var se,le={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1},fe={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},de=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,ce=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,pe=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,ge=/^[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,ve=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,_e=/^[0-9A-F]{1,4}$/i,he={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1},xe=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,$e={"en-US":/^[A-Z]+$/i,"de-DE":/^[A-ZÄÖÜß]+$/i,"es-ES":/^[A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[A-ZÀÂÆÇÉÈÊËÏÎÔŒÙÛÜŸ]+$/i,"nl-NL":/^[A-ZÉËÏÓÖÜ]+$/i,"pl-PL":/^[A-ZĄĆĘŚŁŃÓŻŹ]+$/i,"pt-PT":/^[A-ZÃÁÀÂÇÉÊÍÕÓÔÚÜ]+$/i,"ru-RU":/^[А-ЯЁа-яё]+$/i,"tr-TR":/^[A-ZÇĞİıÖŞÜ]+$/i,ar:/^[ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},Ae={"en-US":/^[0-9A-Z]+$/i,"de-DE":/^[0-9A-ZÄÖÜß]+$/i,"es-ES":/^[0-9A-ZÁÉÍÑÓÚÜ]+$/i,"fr-FR":/^[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,"tr-TR":/^[0-9A-ZÇĞİıÖŞÜ]+$/i,ar:/^[٠١٢٣٤٥٦٧٨٩0-9ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىيًٌٍَُِّْٰ]+$/},me=["AU","GB","HK","IN","NZ","ZA","ZM"],we=0;we