n4s 5.0.2 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/date.development.js +19 -1
- package/dist/cjs/date.production.js +1 -1
- package/dist/cjs/email.development.js +17 -15
- package/dist/cjs/email.production.js +1 -1
- package/dist/es/date.development.js +19 -1
- package/dist/es/date.production.js +1 -1
- package/dist/es/email.development.js +17 -15
- package/dist/es/email.production.js +1 -1
- package/dist/umd/date.development.js +19 -1
- package/dist/umd/date.production.js +1 -1
- package/dist/umd/email.development.js +17 -15
- package/dist/umd/email.production.js +1 -1
- package/package.json +8 -4
|
@@ -126,7 +126,25 @@ function isDate(input, options) {
|
|
|
126
126
|
_iterator.f();
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
var fullYear = dateObj.y;
|
|
130
|
+
|
|
131
|
+
if (dateObj.y.length === 2) {
|
|
132
|
+
var parsedYear = parseInt(dateObj.y, 10);
|
|
133
|
+
|
|
134
|
+
if (isNaN(parsedYear)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
var currentYearLastTwoDigits = new Date().getFullYear() % 100;
|
|
139
|
+
|
|
140
|
+
if (parsedYear < currentYearLastTwoDigits) {
|
|
141
|
+
fullYear = "20".concat(dateObj.y);
|
|
142
|
+
} else {
|
|
143
|
+
fullYear = "19".concat(dateObj.y);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return new Date("".concat(fullYear, "-").concat(dateObj.m, "-").concat(dateObj.d)).getDate() === +dateObj.d;
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
if (!options.strictMode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("n4s");function r(t){return r="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},r(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=r(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function e(t){return n(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;for(var n in r)void 0===t[n]&&(t[n]=r[n]);return t}function i(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,r)||a(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,r){if(t){if("string"==typeof t)return u(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,r):void 0}}function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var c={format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1};var f=/^([\+-]?\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)?)?)?)?$/,
|
|
1
|
+
"use strict";var t=require("n4s");function r(t){return r="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},r(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=r(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function e(t){return n(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;for(var n in r)void 0===t[n]&&(t[n]=r[n]);return t}function i(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,r)||a(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,r){if(t){if("string"==typeof t)return u(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,r):void 0}}function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var c={format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1};var f=/^([\+-]?\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)?)?)?)?$/,l=/^([\+-]?\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]((([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)?)?)?)?$/,d=function(t){var r=t.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);if(r){var n=Number(r[1]),e=Number(r[2]);return n%4==0&&n%100!=0||n%400==0?e<=366:e<=365}var o=t.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number),i=o[1],a=o[2],u=o[3],c=a?"0".concat(a).slice(-2):a,f=u?"0".concat(u).slice(-2):u,l=new Date("".concat(i,"-").concat(c||"01","-").concat(f||"01"));return!a||!u||l.getUTCFullYear()===i&&l.getUTCMonth()+1===a&&l.getUTCDate()===u};t.enforce.extend({isAfter:function(t,r){var n=e((null==r?void 0:r.comparisonDate)||r||Date().toString()),o=e(t);return!!(o&&n&&o>n)},isBefore:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);n(t);var o=e(r),i=e(t);return!!(i&&o&&i<o)},isDate:function(t,r){if(r=o("string"==typeof r?{format:r}:r,c),"string"==typeof t&&(p=r.format,/(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(p))){var n,e=r.delimiters.find((function(t){return-1!==r.format.indexOf(t)})),u=r.strictMode?e:r.delimiters.find((function(r){return-1!==t.indexOf(r)})),f=function(t,r){for(var n=[],e=Math.min(t.length,r.length),o=0;o<e;o++)n.push([t[o],r[o]]);return n}(t.split(u),r.format.toLowerCase().split(e)),l={},d=function(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=a(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){c=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw i}}}}(f);try{for(d.s();!(n=d.n()).done;){var y=i(n.value,2),s=y[0],m=y[1];if(s.length!==m.length)return!1;l[m.charAt(0)]=s}}catch(t){d.e(t)}finally{d.f()}var v=l.y;if(2===l.y.length){var b=parseInt(l.y,10);if(isNaN(b))return!1;v=b<(new Date).getFullYear()%100?"20".concat(l.y):"19".concat(l.y)}return new Date("".concat(v,"-").concat(l.m,"-").concat(l.d)).getDate()===+l.d}var p;return!r.strictMode&&("[object Date]"===Object.prototype.toString.call(t)&&isFinite(t))},isISO8601:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(t);var e=r.strictSeparator?l.test(t):f.test(t);return e&&r.strict?d(t):e}});
|
|
@@ -15,19 +15,6 @@ function assertString(input) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function merge() {
|
|
19
|
-
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
20
|
-
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
21
|
-
|
|
22
|
-
for (var key in defaults) {
|
|
23
|
-
if (typeof obj[key] === 'undefined') {
|
|
24
|
-
obj[key] = defaults[key];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return obj;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
18
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
32
19
|
/* eslint-disable prefer-rest-params */
|
|
33
20
|
|
|
@@ -49,6 +36,19 @@ function isByteLength(str, options) {
|
|
|
49
36
|
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
50
37
|
}
|
|
51
38
|
|
|
39
|
+
function merge() {
|
|
40
|
+
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
41
|
+
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
42
|
+
|
|
43
|
+
for (var key in defaults) {
|
|
44
|
+
if (typeof obj[key] === 'undefined') {
|
|
45
|
+
obj[key] = defaults[key];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return obj;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
52
|
var default_fqdn_options = {
|
|
53
53
|
require_tld: true,
|
|
54
54
|
allow_underscores: false,
|
|
@@ -180,6 +180,7 @@ function isIP(str) {
|
|
|
180
180
|
|
|
181
181
|
var default_email_options = {
|
|
182
182
|
allow_display_name: false,
|
|
183
|
+
allow_underscores: false,
|
|
183
184
|
require_display_name: false,
|
|
184
185
|
allow_utf8_local_part: true,
|
|
185
186
|
require_tld: true,
|
|
@@ -196,7 +197,7 @@ var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
|
|
|
196
197
|
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
|
|
197
198
|
var gmailUserPart = /^[a-z\d]+$/;
|
|
198
199
|
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
|
|
199
|
-
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\
|
|
200
|
+
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
|
|
200
201
|
var quotedEmailUserUtf8 = /^([\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;
|
|
201
202
|
var defaultMaxEmailLength = 254;
|
|
202
203
|
/* eslint-enable max-len */
|
|
@@ -320,7 +321,8 @@ function isEmail(str, options) {
|
|
|
320
321
|
|
|
321
322
|
if (!isFQDN(domain, {
|
|
322
323
|
require_tld: options.require_tld,
|
|
323
|
-
ignore_max_length: options.ignore_max_length
|
|
324
|
+
ignore_max_length: options.ignore_max_length,
|
|
325
|
+
allow_underscores: options.allow_underscores
|
|
324
326
|
})) {
|
|
325
327
|
if (!options.allow_ip_domain) {
|
|
326
328
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("n4s");function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(
|
|
1
|
+
"use strict";var t=require("n4s");function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(t){return r="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},r(t)}function o(t,e){var o,i;n(t),"object"===r(e)?(o=e.min||0,i=e.max):(o=arguments[1],i=arguments[2]);var a=encodeURI(t).split(/%..|./).length-1;return a>=o&&(void 0===i||a<=i)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;for(var n in e)void 0===t[n]&&(t[n]=e[n]);return t}var a={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var c="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",l="(".concat(c,"[.]){3}").concat(c),u=new RegExp("^".concat(l,"$")),s="(?:[0-9a-fA-F]{1,4})",f=new RegExp("^("+"(?:".concat(s,":){7}(?:").concat(s,"|:)|")+"(?:".concat(s,":){6}(?:").concat(l,"|:").concat(s,"|:)|")+"(?:".concat(s,":){5}(?::").concat(l,"|(:").concat(s,"){1,2}|:)|")+"(?:".concat(s,":){4}(?:(:").concat(s,"){0,1}:").concat(l,"|(:").concat(s,"){1,3}|:)|")+"(?:".concat(s,":){3}(?:(:").concat(s,"){0,2}:").concat(l,"|(:").concat(s,"){1,4}|:)|")+"(?:".concat(s,":){2}(?:(:").concat(s,"){0,3}:").concat(l,"|(:").concat(s,"){1,5}|:)|")+"(?:".concat(s,":){1}(?:(:").concat(s,"){0,4}:").concat(l,"|(:").concat(s,"){1,6}|:)|")+"(?::((?::".concat(s,"){0,5}:").concat(l,"|(?::").concat(s,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function _(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return n(t),(e=String(e))?"4"===e?u.test(t):"6"===e&&f.test(t):_(t,4)||_(t,6)}var x={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},d=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,g=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,m=/^[a-z\d]+$/,p=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,F=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,h=/^([\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;t.enforce.extend({isEmail:function(t,e){if(n(t),(e=i(e,x)).require_display_name||e.allow_display_name){var r=t.match(d);if(r){var c=r[1];if(t=t.replace(c,"").replace(/(^<|>$)/g,""),c.endsWith(" ")&&(c=c.slice(0,-1)),!function(t){var e=t.replace(/^"(.+)"$/,"$1");if(!e.trim())return!1;if(/[\.";<>]/.test(e)){if(e===t)return!1;if(e.split('"').length!==e.split('\\"').length)return!1}return!0}(c))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&t.length>254)return!1;var l=t.split("@"),u=l.pop(),s=u.toLowerCase();if(e.host_blacklist.includes(s))return!1;if(e.host_whitelist.length>0&&!e.host_whitelist.includes(s))return!1;var f=l.join("@");if(e.domain_specific_validation&&("gmail.com"===s||"googlemail.com"===s)){var y=(f=f.toLowerCase()).split("+")[0];if(!o(y.replace(/\./g,""),{min:6,max:30}))return!1;for(var b=y.split("."),w=0;w<b.length;w++)if(!m.test(b[w]))return!1}if(!(!1!==e.ignore_max_length||o(f,{max:64})&&o(u,{max:254})))return!1;if(!function(t,e){n(t),(e=i(e,a)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===e.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var r=t.split("."),o=r[r.length-1];if(e.require_tld){if(r.length<2)return!1;if(!e.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(o))return!1;if(/\s/.test(o))return!1}return!(!e.allow_numeric_tld&&/^\d+$/.test(o))&&r.every((function(t){return!(t.length>63&&!e.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!e.allow_underscores&&/_/.test(t))}))}(u,{require_tld:e.require_tld,ignore_max_length:e.ignore_max_length,allow_underscores:e.allow_underscores})){if(!e.allow_ip_domain)return!1;if(!_(u)){if(!u.startsWith("[")||!u.endsWith("]"))return!1;var v=u.slice(1,-1);if(0===v.length||!_(v))return!1}}if('"'===f[0])return f=f.slice(1,f.length-1),e.allow_utf8_local_part?h.test(f):p.test(f);for(var $=e.allow_utf8_local_part?F:g,D=f.split("."),S=0;S<D.length;S++)if(!$.test(D[S]))return!1;return!e.blacklisted_chars||-1===f.search(new RegExp("[".concat(e.blacklisted_chars,"]+"),"g"))}});
|
|
@@ -124,7 +124,25 @@ function isDate(input, options) {
|
|
|
124
124
|
_iterator.f();
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
var fullYear = dateObj.y;
|
|
128
|
+
|
|
129
|
+
if (dateObj.y.length === 2) {
|
|
130
|
+
var parsedYear = parseInt(dateObj.y, 10);
|
|
131
|
+
|
|
132
|
+
if (isNaN(parsedYear)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var currentYearLastTwoDigits = new Date().getFullYear() % 100;
|
|
137
|
+
|
|
138
|
+
if (parsedYear < currentYearLastTwoDigits) {
|
|
139
|
+
fullYear = "20".concat(dateObj.y);
|
|
140
|
+
} else {
|
|
141
|
+
fullYear = "19".concat(dateObj.y);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return new Date("".concat(fullYear, "-").concat(dateObj.m, "-").concat(dateObj.d)).getDate() === +dateObj.d;
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
if (!options.strictMode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{enforce as t}from"n4s";function r(t){return r="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},r(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=r(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function e(t){return n(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;for(var n in r)void 0===t[n]&&(t[n]=r[n]);return t}function i(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,r)||a(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,r){if(t){if("string"==typeof t)return u(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,r):void 0}}function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var c={format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1};var f=/^([\+-]?\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)?)?)?)?$/,
|
|
1
|
+
import{enforce as t}from"n4s";function r(t){return r="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},r(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=r(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function e(t){return n(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;for(var n in r)void 0===t[n]&&(t[n]=r[n]);return t}function i(t,r){return function(t){if(Array.isArray(t))return t}(t)||function(t,r){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var n=[],e=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(e=(a=u.next()).done)&&(n.push(a.value),!r||n.length!==r);e=!0);}catch(t){o=!0,i=t}finally{try{e||null==u.return||u.return()}finally{if(o)throw i}}return n}(t,r)||a(t,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,r){if(t){if("string"==typeof t)return u(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,r):void 0}}function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=new Array(r);n<r;n++)e[n]=t[n];return e}var c={format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1};var f=/^([\+-]?\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)?)?)?)?$/,l=/^([\+-]?\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]((([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)?)?)?)?$/,d=function(t){var r=t.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);if(r){var n=Number(r[1]),e=Number(r[2]);return n%4==0&&n%100!=0||n%400==0?e<=366:e<=365}var o=t.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number),i=o[1],a=o[2],u=o[3],c=a?"0".concat(a).slice(-2):a,f=u?"0".concat(u).slice(-2):u,l=new Date("".concat(i,"-").concat(c||"01","-").concat(f||"01"));return!a||!u||l.getUTCFullYear()===i&&l.getUTCMonth()+1===a&&l.getUTCDate()===u};t.extend({isAfter:function(t,r){var n=e((null==r?void 0:r.comparisonDate)||r||Date().toString()),o=e(t);return!!(o&&n&&o>n)},isBefore:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);n(t);var o=e(r),i=e(t);return!!(i&&o&&i<o)},isDate:function(t,r){if(r=o("string"==typeof r?{format:r}:r,c),"string"==typeof t&&(p=r.format,/(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(p))){var n,e=r.delimiters.find((function(t){return-1!==r.format.indexOf(t)})),u=r.strictMode?e:r.delimiters.find((function(r){return-1!==t.indexOf(r)})),f=function(t,r){for(var n=[],e=Math.min(t.length,r.length),o=0;o<e;o++)n.push([t[o],r[o]]);return n}(t.split(u),r.format.toLowerCase().split(e)),l={},d=function(t,r){var n;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(n=a(t))||r&&t&&"number"==typeof t.length){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return u=t.done,t},e:function(t){c=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw i}}}}(f);try{for(d.s();!(n=d.n()).done;){var y=i(n.value,2),s=y[0],m=y[1];if(s.length!==m.length)return!1;l[m.charAt(0)]=s}}catch(t){d.e(t)}finally{d.f()}var v=l.y;if(2===l.y.length){var b=parseInt(l.y,10);if(isNaN(b))return!1;v=b<(new Date).getFullYear()%100?"20".concat(l.y):"19".concat(l.y)}return new Date("".concat(v,"-").concat(l.m,"-").concat(l.d)).getDate()===+l.d}var p;return!r.strictMode&&("[object Date]"===Object.prototype.toString.call(t)&&isFinite(t))},isISO8601:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n(t);var e=r.strictSeparator?l.test(t):f.test(t);return e&&r.strict?d(t):e}});
|
|
@@ -13,19 +13,6 @@ function assertString(input) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function merge() {
|
|
17
|
-
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
|
-
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
19
|
-
|
|
20
|
-
for (var key in defaults) {
|
|
21
|
-
if (typeof obj[key] === 'undefined') {
|
|
22
|
-
obj[key] = defaults[key];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
16
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
30
17
|
/* eslint-disable prefer-rest-params */
|
|
31
18
|
|
|
@@ -47,6 +34,19 @@ function isByteLength(str, options) {
|
|
|
47
34
|
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
48
35
|
}
|
|
49
36
|
|
|
37
|
+
function merge() {
|
|
38
|
+
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
39
|
+
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
40
|
+
|
|
41
|
+
for (var key in defaults) {
|
|
42
|
+
if (typeof obj[key] === 'undefined') {
|
|
43
|
+
obj[key] = defaults[key];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
50
|
var default_fqdn_options = {
|
|
51
51
|
require_tld: true,
|
|
52
52
|
allow_underscores: false,
|
|
@@ -178,6 +178,7 @@ function isIP(str) {
|
|
|
178
178
|
|
|
179
179
|
var default_email_options = {
|
|
180
180
|
allow_display_name: false,
|
|
181
|
+
allow_underscores: false,
|
|
181
182
|
require_display_name: false,
|
|
182
183
|
allow_utf8_local_part: true,
|
|
183
184
|
require_tld: true,
|
|
@@ -194,7 +195,7 @@ var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)</i;
|
|
|
194
195
|
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
|
|
195
196
|
var gmailUserPart = /^[a-z\d]+$/;
|
|
196
197
|
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
|
|
197
|
-
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\
|
|
198
|
+
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
|
|
198
199
|
var quotedEmailUserUtf8 = /^([\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;
|
|
199
200
|
var defaultMaxEmailLength = 254;
|
|
200
201
|
/* eslint-enable max-len */
|
|
@@ -318,7 +319,8 @@ function isEmail(str, options) {
|
|
|
318
319
|
|
|
319
320
|
if (!isFQDN(domain, {
|
|
320
321
|
require_tld: options.require_tld,
|
|
321
|
-
ignore_max_length: options.ignore_max_length
|
|
322
|
+
ignore_max_length: options.ignore_max_length,
|
|
323
|
+
allow_underscores: options.allow_underscores
|
|
322
324
|
})) {
|
|
323
325
|
if (!options.allow_ip_domain) {
|
|
324
326
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{enforce as t}from"n4s";function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(
|
|
1
|
+
import{enforce as t}from"n4s";function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(t){return r="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},r(t)}function o(t,e){var o,i;n(t),"object"===r(e)?(o=e.min||0,i=e.max):(o=arguments[1],i=arguments[2]);var a=encodeURI(t).split(/%..|./).length-1;return a>=o&&(void 0===i||a<=i)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;for(var n in e)void 0===t[n]&&(t[n]=e[n]);return t}var a={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var l="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",c="(".concat(l,"[.]){3}").concat(l),u=new RegExp("^".concat(c,"$")),s="(?:[0-9a-fA-F]{1,4})",f=new RegExp("^("+"(?:".concat(s,":){7}(?:").concat(s,"|:)|")+"(?:".concat(s,":){6}(?:").concat(c,"|:").concat(s,"|:)|")+"(?:".concat(s,":){5}(?::").concat(c,"|(:").concat(s,"){1,2}|:)|")+"(?:".concat(s,":){4}(?:(:").concat(s,"){0,1}:").concat(c,"|(:").concat(s,"){1,3}|:)|")+"(?:".concat(s,":){3}(?:(:").concat(s,"){0,2}:").concat(c,"|(:").concat(s,"){1,4}|:)|")+"(?:".concat(s,":){2}(?:(:").concat(s,"){0,3}:").concat(c,"|(:").concat(s,"){1,5}|:)|")+"(?:".concat(s,":){1}(?:(:").concat(s,"){0,4}:").concat(c,"|(:").concat(s,"){1,6}|:)|")+"(?::((?::".concat(s,"){0,5}:").concat(c,"|(?::").concat(s,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function _(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return n(t),(e=String(e))?"4"===e?u.test(t):"6"===e&&f.test(t):_(t,4)||_(t,6)}var x={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},d=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,g=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,m=/^[a-z\d]+$/,p=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,F=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,h=/^([\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;t.extend({isEmail:function(t,e){if(n(t),(e=i(e,x)).require_display_name||e.allow_display_name){var r=t.match(d);if(r){var l=r[1];if(t=t.replace(l,"").replace(/(^<|>$)/g,""),l.endsWith(" ")&&(l=l.slice(0,-1)),!function(t){var e=t.replace(/^"(.+)"$/,"$1");if(!e.trim())return!1;if(/[\.";<>]/.test(e)){if(e===t)return!1;if(e.split('"').length!==e.split('\\"').length)return!1}return!0}(l))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&t.length>254)return!1;var c=t.split("@"),u=c.pop(),s=u.toLowerCase();if(e.host_blacklist.includes(s))return!1;if(e.host_whitelist.length>0&&!e.host_whitelist.includes(s))return!1;var f=c.join("@");if(e.domain_specific_validation&&("gmail.com"===s||"googlemail.com"===s)){var y=(f=f.toLowerCase()).split("+")[0];if(!o(y.replace(/\./g,""),{min:6,max:30}))return!1;for(var b=y.split("."),w=0;w<b.length;w++)if(!m.test(b[w]))return!1}if(!(!1!==e.ignore_max_length||o(f,{max:64})&&o(u,{max:254})))return!1;if(!function(t,e){n(t),(e=i(e,a)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===e.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var r=t.split("."),o=r[r.length-1];if(e.require_tld){if(r.length<2)return!1;if(!e.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(o))return!1;if(/\s/.test(o))return!1}return!(!e.allow_numeric_tld&&/^\d+$/.test(o))&&r.every((function(t){return!(t.length>63&&!e.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!e.allow_underscores&&/_/.test(t))}))}(u,{require_tld:e.require_tld,ignore_max_length:e.ignore_max_length,allow_underscores:e.allow_underscores})){if(!e.allow_ip_domain)return!1;if(!_(u)){if(!u.startsWith("[")||!u.endsWith("]"))return!1;var v=u.slice(1,-1);if(0===v.length||!_(v))return!1}}if('"'===f[0])return f=f.slice(1,f.length-1),e.allow_utf8_local_part?h.test(f):p.test(f);for(var $=e.allow_utf8_local_part?F:g,D=f.split("."),S=0;S<D.length;S++)if(!$.test(D[S]))return!1;return!e.blacklisted_chars||-1===f.search(new RegExp("[".concat(e.blacklisted_chars,"]+"),"g"))}});
|
|
@@ -128,7 +128,25 @@
|
|
|
128
128
|
_iterator.f();
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
var fullYear = dateObj.y;
|
|
132
|
+
|
|
133
|
+
if (dateObj.y.length === 2) {
|
|
134
|
+
var parsedYear = parseInt(dateObj.y, 10);
|
|
135
|
+
|
|
136
|
+
if (isNaN(parsedYear)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var currentYearLastTwoDigits = new Date().getFullYear() % 100;
|
|
141
|
+
|
|
142
|
+
if (parsedYear < currentYearLastTwoDigits) {
|
|
143
|
+
fullYear = "20".concat(dateObj.y);
|
|
144
|
+
} else {
|
|
145
|
+
fullYear = "19".concat(dateObj.y);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return new Date("".concat(fullYear, "-").concat(dateObj.m, "-").concat(dateObj.d)).getDate() === +dateObj.d;
|
|
132
150
|
}
|
|
133
151
|
|
|
134
152
|
if (!options.strictMode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("n4s")):"function"==typeof define&&define.amd?define(["n4s"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).n4s)}(this,(function(t){"use strict";function n(t){return n="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},n(t)}function
|
|
1
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(require("n4s")):"function"==typeof define&&define.amd?define(["n4s"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).n4s)}(this,(function(t){"use strict";function n(t){return n="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},n(t)}function e(t){if(!("string"==typeof t||t instanceof String)){var e=n(t);throw null===t?e="null":"object"===e&&(e=t.constructor.name),new TypeError("Expected a string but received a ".concat(e))}}function r(t){return e(t),t=Date.parse(t),isNaN(t)?null:new Date(t)}function o(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;for(var e in n)void 0===t[e]&&(t[e]=n[e]);return t}function i(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(e.push(a.value),!n||e.length!==n);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return e}(t,n)||a(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,n){if(t){if("string"==typeof t)return u(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,n):void 0}}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}var c={format:"YYYY/MM/DD",delimiters:["/","-"],strictMode:!1};var f=/^([\+-]?\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)?)?)?)?$/,d=/^([\+-]?\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]((([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)?)?)?)?$/,l=function(t){var n=t.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/);if(n){var e=Number(n[1]),r=Number(n[2]);return e%4==0&&e%100!=0||e%400==0?r<=366:r<=365}var o=t.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number),i=o[1],a=o[2],u=o[3],c=a?"0".concat(a).slice(-2):a,f=u?"0".concat(u).slice(-2):u,d=new Date("".concat(i,"-").concat(c||"01","-").concat(f||"01"));return!a||!u||d.getUTCFullYear()===i&&d.getUTCMonth()+1===a&&d.getUTCDate()===u};t.enforce.extend({isAfter:function(t,n){var e=r((null==n?void 0:n.comparisonDate)||n||Date().toString()),o=r(t);return!!(o&&e&&o>e)},isBefore:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:String(new Date);e(t);var o=r(n),i=r(t);return!!(i&&o&&i<o)},isDate:function(t,n){if(n=o("string"==typeof n?{format:n}:n,c),"string"==typeof t&&(b=n.format,/(^(y{4}|y{2})[.\/-](m{1,2})[.\/-](d{1,2})$)|(^(m{1,2})[.\/-](d{1,2})[.\/-]((y{4}|y{2})$))|(^(d{1,2})[.\/-](m{1,2})[.\/-]((y{4}|y{2})$))/gi.test(b))){var e,r=n.delimiters.find((function(t){return-1!==n.format.indexOf(t)})),u=n.strictMode?r:n.delimiters.find((function(n){return-1!==t.indexOf(n)})),f=function(t,n){for(var e=[],r=Math.min(t.length,n.length),o=0;o<r;o++)e.push([t[o],n[o]]);return e}(t.split(u),n.format.toLowerCase().split(r)),d={},l=function(t,n){var e;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=a(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return u=t.done,t},e:function(t){c=!0,i=t},f:function(){try{u||null==e.return||e.return()}finally{if(c)throw i}}}}(f);try{for(l.s();!(e=l.n()).done;){var s=i(e.value,2),y=s[0],m=s[1];if(y.length!==m.length)return!1;d[m.charAt(0)]=y}}catch(t){l.e(t)}finally{l.f()}var v=d.y;if(2===d.y.length){var p=parseInt(d.y,10);if(isNaN(p))return!1;v=p<(new Date).getFullYear()%100?"20".concat(d.y):"19".concat(d.y)}return new Date("".concat(v,"-").concat(d.m,"-").concat(d.d)).getDate()===+d.d}var b;return!n.strictMode&&("[object Date]"===Object.prototype.toString.call(t)&&isFinite(t))},isISO8601:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e(t);var r=n.strictSeparator?d.test(t):f.test(t);return r&&n.strict?l(t):r}})}));
|
|
@@ -17,19 +17,6 @@
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function merge() {
|
|
21
|
-
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
22
|
-
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
23
|
-
|
|
24
|
-
for (var key in defaults) {
|
|
25
|
-
if (typeof obj[key] === 'undefined') {
|
|
26
|
-
obj[key] = defaults[key];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
20
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
34
21
|
/* eslint-disable prefer-rest-params */
|
|
35
22
|
|
|
@@ -51,6 +38,19 @@
|
|
|
51
38
|
return len >= min && (typeof max === 'undefined' || len <= max);
|
|
52
39
|
}
|
|
53
40
|
|
|
41
|
+
function merge() {
|
|
42
|
+
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
43
|
+
var defaults = arguments.length > 1 ? arguments[1] : undefined;
|
|
44
|
+
|
|
45
|
+
for (var key in defaults) {
|
|
46
|
+
if (typeof obj[key] === 'undefined') {
|
|
47
|
+
obj[key] = defaults[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return obj;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
54
|
var default_fqdn_options = {
|
|
55
55
|
require_tld: true,
|
|
56
56
|
allow_underscores: false,
|
|
@@ -182,6 +182,7 @@
|
|
|
182
182
|
|
|
183
183
|
var default_email_options = {
|
|
184
184
|
allow_display_name: false,
|
|
185
|
+
allow_underscores: false,
|
|
185
186
|
require_display_name: false,
|
|
186
187
|
allow_utf8_local_part: true,
|
|
187
188
|
require_tld: true,
|
|
@@ -198,7 +199,7 @@
|
|
|
198
199
|
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i;
|
|
199
200
|
var gmailUserPart = /^[a-z\d]+$/;
|
|
200
201
|
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i;
|
|
201
|
-
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\
|
|
202
|
+
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i;
|
|
202
203
|
var quotedEmailUserUtf8 = /^([\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;
|
|
203
204
|
var defaultMaxEmailLength = 254;
|
|
204
205
|
/* eslint-enable max-len */
|
|
@@ -322,7 +323,8 @@
|
|
|
322
323
|
|
|
323
324
|
if (!isFQDN(domain, {
|
|
324
325
|
require_tld: options.require_tld,
|
|
325
|
-
ignore_max_length: options.ignore_max_length
|
|
326
|
+
ignore_max_length: options.ignore_max_length,
|
|
327
|
+
allow_underscores: options.allow_underscores
|
|
326
328
|
})) {
|
|
327
329
|
if (!options.allow_ip_domain) {
|
|
328
330
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("n4s")):"function"==typeof define&&define.amd?define(["n4s"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).n4s)}(this,(function(t){"use strict";function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("n4s")):"function"==typeof define&&define.amd?define(["n4s"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).n4s)}(this,(function(t){"use strict";function e(t){return e="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},e(t)}function n(t){if(!("string"==typeof t||t instanceof String)){var n=e(t);throw null===t?n="null":"object"===n&&(n=t.constructor.name),new TypeError("Expected a string but received a ".concat(n))}}function r(t){return r="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},r(t)}function o(t,e){var o,i;n(t),"object"===r(e)?(o=e.min||0,i=e.max):(o=arguments[1],i=arguments[2]);var l=encodeURI(t).split(/%..|./).length-1;return l>=o&&(void 0===i||l<=i)}function i(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;for(var n in e)void 0===t[n]&&(t[n]=e[n]);return t}var l={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var a="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",c="(".concat(a,"[.]){3}").concat(a),u=new RegExp("^".concat(c,"$")),s="(?:[0-9a-fA-F]{1,4})",f=new RegExp("^("+"(?:".concat(s,":){7}(?:").concat(s,"|:)|")+"(?:".concat(s,":){6}(?:").concat(c,"|:").concat(s,"|:)|")+"(?:".concat(s,":){5}(?::").concat(c,"|(:").concat(s,"){1,2}|:)|")+"(?:".concat(s,":){4}(?:(:").concat(s,"){0,1}:").concat(c,"|(:").concat(s,"){1,3}|:)|")+"(?:".concat(s,":){3}(?:(:").concat(s,"){0,2}:").concat(c,"|(:").concat(s,"){1,4}|:)|")+"(?:".concat(s,":){2}(?:(:").concat(s,"){0,3}:").concat(c,"|(:").concat(s,"){1,5}|:)|")+"(?:".concat(s,":){1}(?:(:").concat(s,"){0,4}:").concat(c,"|(:").concat(s,"){1,6}|:)|")+"(?::((?::".concat(s,"){0,5}:").concat(c,"|(?::").concat(s,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function _(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return n(t),(e=String(e))?"4"===e?u.test(t):"6"===e&&f.test(t):_(t,4)||_(t,6)}var d={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},x=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,g=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,p=/^[a-z\d]+$/,m=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,h=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,F=/^([\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;t.enforce.extend({isEmail:function(t,e){if(n(t),(e=i(e,d)).require_display_name||e.allow_display_name){var r=t.match(x);if(r){var a=r[1];if(t=t.replace(a,"").replace(/(^<|>$)/g,""),a.endsWith(" ")&&(a=a.slice(0,-1)),!function(t){var e=t.replace(/^"(.+)"$/,"$1");if(!e.trim())return!1;if(/[\.";<>]/.test(e)){if(e===t)return!1;if(e.split('"').length!==e.split('\\"').length)return!1}return!0}(a))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&t.length>254)return!1;var c=t.split("@"),u=c.pop(),s=u.toLowerCase();if(e.host_blacklist.includes(s))return!1;if(e.host_whitelist.length>0&&!e.host_whitelist.includes(s))return!1;var f=c.join("@");if(e.domain_specific_validation&&("gmail.com"===s||"googlemail.com"===s)){var y=(f=f.toLowerCase()).split("+")[0];if(!o(y.replace(/\./g,""),{min:6,max:30}))return!1;for(var b=y.split("."),w=0;w<b.length;w++)if(!p.test(b[w]))return!1}if(!(!1!==e.ignore_max_length||o(f,{max:64})&&o(u,{max:254})))return!1;if(!function(t,e){n(t),(e=i(e,l)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===e.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var r=t.split("."),o=r[r.length-1];if(e.require_tld){if(r.length<2)return!1;if(!e.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(o))return!1;if(/\s/.test(o))return!1}return!(!e.allow_numeric_tld&&/^\d+$/.test(o))&&r.every((function(t){return!(t.length>63&&!e.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!e.allow_underscores&&/_/.test(t))}))}(u,{require_tld:e.require_tld,ignore_max_length:e.ignore_max_length,allow_underscores:e.allow_underscores})){if(!e.allow_ip_domain)return!1;if(!_(u)){if(!u.startsWith("[")||!u.endsWith("]"))return!1;var v=u.slice(1,-1);if(0===v.length||!_(v))return!1}}if('"'===f[0])return f=f.slice(1,f.length-1),e.allow_utf8_local_part?F.test(f):m.test(f);for(var $=e.allow_utf8_local_part?h:g,D=f.split("."),S=0;S<D.length;S++)if(!$.test(D[S]))return!1;return!e.blacklisted_chars||-1===f.search(new RegExp("[".concat(e.blacklisted_chars,"]+"),"g"))}})}));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.0.
|
|
2
|
+
"version": "5.0.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "./dist/cjs/n4s.js",
|
|
5
5
|
"types": "./types/n4s.d.ts",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"vest",
|
|
11
11
|
"enforce",
|
|
12
12
|
"n4s",
|
|
13
|
-
"validation"
|
|
13
|
+
"validation",
|
|
14
|
+
"assertion",
|
|
15
|
+
"schema validation",
|
|
16
|
+
"form validation",
|
|
17
|
+
"validation library"
|
|
14
18
|
],
|
|
15
19
|
"scripts": {
|
|
16
20
|
"test": "vx test",
|
|
@@ -21,8 +25,8 @@
|
|
|
21
25
|
"vest-utils": "^1.0.1"
|
|
22
26
|
},
|
|
23
27
|
"devDependencies": {
|
|
24
|
-
"@types/validator": "^13.
|
|
25
|
-
"validator": "^13.
|
|
28
|
+
"@types/validator": "^13.11.1",
|
|
29
|
+
"validator": "^13.11.0"
|
|
26
30
|
},
|
|
27
31
|
"vxAllowResolve": [
|
|
28
32
|
"validator"
|