23 lines
31 KiB
JavaScript
23 lines
31 KiB
JavaScript
|
/*!
|
|||
|
* Copyright (c) 2018 Chris O'Hara <cohara87@gmail.com>
|
|||
|
*
|
|||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|||
|
* a copy of this software and associated documentation files (the
|
|||
|
* "Software"), to deal in the Software without restriction, including
|
|||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|||
|
* permit persons to whom the Software is furnished to do so, subject to
|
|||
|
* the following conditions:
|
|||
|
*
|
|||
|
* The above copyright notice and this permission notice shall be
|
|||
|
* included in all copies or substantial portions of the Software.
|
|||
|
*
|
|||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|||
|
* 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=0<arguments.length&&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 h(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=encodeURI(e).split(/%..|./).length-1;return r<=o&&(void 0===i||o<=i)}var l={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};function v(e,t){g(e),(t=A(t,l)).allow_trailing_dot&&"."===e[e.length-1]&&(e=e.substring(0,e.length-1));for(var r=e.split("."),i=0;i<r.length;i++)if(63<r[i].length)return!1;if(t.require_tld){var o=r.pop();if(!r.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(o))return!1;if(/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20]/.test(o))return!1}for(var n,a=0;a<r.length;a++){if(n=r[a],t.allow_underscores&&(n=n.replace(/_/g,"")),!/^[a-z\u00a1-\uffff0-9-]+$/i.test(n))return!1;if(/[\uff01-\uff5e]/.test(n))return!1;if("-"===n[0]||"-"===n[n.length-1])return!1}return!0}var s=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,u=/^[0-9A-F]{1,4}$/i;function m(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"";if(g(e),!(t=String(t)))return m(e,4)||m(e,6);if("4"===t)return!!s.test(e)&&e.split(".").sort(function(e,t){return e-t})[3]<=255;if("6"!==t)return!1;var r=e.split(":"),i=!1,o=m(r[r.length-1],4),n=o?7:8;if(r.length>n)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<r.length;++a)if(""===r[a]&&0<a&&a<r.length-1){if(i)return!1;i=!0}else if(o&&a===r.length-1);else if(!u.test(r[a]))return!1;return i?1<=r.length:r.length===n}var $={allow_display_name:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0},_=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\,\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/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.length;r++){var i=t[r];if(e===i||(o=i,"[object RegExp]"===Object.prototype.toString.call(o)&&i.test(e)))return!0}var o;return!1}var i=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,d=/^([0-9a-fA-F]){12}$/;var C=/^\d{1,2}$/;for(var e,M={"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":/
|