Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastest-validator

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastest-validator - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

8

CHANGELOG.md
--------------------------------------------------
<a name="1.4.1"></a>
# 1.4.1 (2020-05-13)
## Changes
- Fix `custom` function issue in `array` rule and in root-level [#136](https://github.com/icebob/fastest-validator/issues/136), [#137](https://github.com/icebob/fastest-validator/issues/137)
--------------------------------------------------
<a name="1.4.0"></a>

@@ -63,3 +70,2 @@ # 1.4.0 (2020-05-08)

## Changes
--------------------------------------------------

@@ -66,0 +72,0 @@ <a name="1.3.0"></a>

33

dist/index.js

@@ -145,15 +145,6 @@ (function (global, factory) {

var itemPath = path + "[]";
var rule = this.getRuleFromSchema(schema.items);
var innerSource = "\n\t\t\tarr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : \"\") + \"[\" + i + \"]\", parent, errors, context);\n\t\t\t" + (this.makeCustomValidator({ vName: "arr[i]", path: path, schema: rule.schema, context: context, messages: messages })) + "\n\t\t";
src.push(this.compileRule(rule, context, path, innerSource, "arr[i]"));
/*
const res = rule.ruleFunction.call(this, rule, path, context);
context.rules[context.index] = rule;
if (res.source) {
const fn = new Function("value", "field", "parent", "errors", "context", res.source);
context.fn[context.index] = fn;
src.push(`arr[i] = context.fn[${context.index}](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context);`);
}
context.index++;
*/
var innerSource = "\n\t\t\tarr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : \"\") + \"[\" + i + \"]\", parent, errors, context);\n\t\t\t" + (this.makeCustomValidator({ vName: "arr[i]", path: itemPath, schema: rule.schema, context: context, messages: messages })) + "\n\t\t";
src.push(this.compileRule(rule, context, itemPath, innerSource, "arr[i]"));
src.push("\n\t\t\t}\n\t\t");

@@ -916,6 +907,8 @@ }

"var errors = [];",
"var field;" ];
"var field;",
"var parent = null;" ];
var rule = this.getRuleFromSchema(schema);
sourceCode.push(this.compileRule(rule, context, null, "context.fn[%%INDEX%%](value, field, null, errors, context);", "value"));
sourceCode.push(("\n\t\t\t\t" + (this.makeCustomValidator({ path: "$$root", schema: rule.schema, context: context, messages: rule.messages })) + "\n\t\t"));

@@ -975,4 +968,5 @@ sourceCode.push("if (errors.length) {");

if (context.customs[path]) { context.customs[path].schema = rule.schema; }
else { context.customs[path] = { schema: rule.schema }; }
var customPath = path != null ? path : "$$root";
if (context.customs[customPath]) { context.customs[customPath].schema = rule.schema; }
else { context.customs[customPath] = { schema: rule.schema }; }

@@ -1113,10 +1107,11 @@ context.index++;

if (typeof schema[fnName] == "function") {
if (context.customs[path]) { context.customs[path].messages = messages; }
else { context.customs[path] = { messages: messages }; }
var customPath = path != null ? path : "$$root";
if (context.customs[customPath]) { context.customs[customPath].messages = messages; }
else { context.customs[customPath] = { messages: messages }; }
if (this.opts.useNewCustomCheckerFunction) {
return ("\n\t\t\t\t\tconst rule = context.customs[\"" + path + "\"];\n\t\t\t\t\tconst fnCustomErrors = [];\n\t\t\t\t\t" + vName + " = rule.schema." + fnName + ".call(this, " + vName + ", fnCustomErrors, rule.schema, \"" + path + "\", parent, context);\n\t\t\t\t\tif (Array.isArray(fnCustomErrors)) {\n\t\t\t\t\tfnCustomErrors.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t");
return ("\n\t\t\t\t\tconst rule = context.customs[\"" + customPath + "\"];\n\t\t\t\t\tconst fnCustomErrors = [];\n\t\t\t\t\t" + vName + " = rule.schema." + fnName + ".call(this, " + vName + ", fnCustomErrors, rule.schema, \"" + path + "\", parent, context);\n\t\t\t\t\tif (Array.isArray(fnCustomErrors)) {\n\t\t\t\t\tfnCustomErrors.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t");
}
return ("\n\t\t\t\tconst rule = context.customs[\"" + path + "\"];\n\t\t\t\tconst res = rule.schema." + fnName + ".call(this, " + vName + ", rule.schema, \"" + path + "\", parent, context);\n\t\t\t\tif (Array.isArray(res)) {\n\t\t\t\t\tres.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t");
return ("\n\t\t\t\tconst rule = context.customs[\"" + customPath + "\"];\n\t\t\t\tconst res = rule.schema." + fnName + ".call(this, " + vName + ", rule.schema, \"" + path + "\", parent, context);\n\t\t\t\tif (Array.isArray(res)) {\n\t\t\t\t\tres.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t");
}

@@ -1123,0 +1118,0 @@ return "";

@@ -1,1 +0,1 @@

"use strict";function w(){function t(t){this.opts={messages:E({},N)},this.defaults={},t&&(E(this.opts,t),t.defaults&&E(this.defaults,t.defaults)),this.messages=this.opts.messages,this.rules={any:x,array:b,boolean:y,class:g,custom:v,date:d,email:m,enum:h,equal:p,forbidden:c,function:f,multi:o,number:l,object:u,string:i,url:s,uuid:a,mac:r,luhn:n},this.aliases={},this.cache=new Map}function e(t){return O||(O=k(),j={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},w=k(),_={language:"js",theme:w.fromJson({keyword:["white","bold"],built_in:"magenta",literal:"cyan",number:"magenta",regexp:"red",string:["yellow","bold"],symbol:"plain",class:"blue",attr:"plain",function:["white","bold"],title:"plain",params:"green",comment:"grey"})}),t=O.format(t,j),w.highlight(t,_)}function n(t){return t=t.messages,{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+'\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (typeof value !== "string")\n\t\t\t\tvalue = String(value);\n\n\t\t\tval = value.replace(/\\D+/g, "");\n\n\t\t\tvar array = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];\n\t\t\tvar len = val ? val.length : 0,\n\t\t\t\tbit = 1,\n\t\t\t\tsum = 0;\n\t\t\twhile (len--) {\n\t\t\t\tsum += !(bit ^= 1) ? parseInt(val[len], 10) : array[val[len]];\n\t\t\t}\n\n\t\t\tif (!(sum % 10 === 0 && sum > 0)) {\n\t\t\t\t'+this.makeError({type:"luhn",actual:"value",messages:t})+"\n\t\t\t}\n\n\t\t\treturn value;\n\t\t"}}function r(t){return t=t.messages,{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tvar v = value.toLowerCase();\n\t\t\tif (!"+L.toString()+".test(v)) {\n\t\t\t\t"+this.makeError({type:"mac",actual:"value",messages:t})+"\n\t\t\t}\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function a(t){var e=t.schema;t=t.messages;var n=[];return n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar val = value.toLowerCase();\n\t\tif (!"+$.toString()+".test(val)) {\n\t\t\t"+this.makeError({type:"uuid",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tconst version = val.charAt(14) | 0;\n\t"),e.version&&n.push("\n\t\t\tif ("+e.version+" !== version) {\n\t\t\t\t"+this.makeError({type:"uuidVersion",expected:e.version,actual:"version",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),n.push('\n\t\tswitch (version) {\n\t\tcase 1:\n\t\tcase 2:\n\t\t\tbreak;\n\t\tcase 3:\n\t\tcase 4:\n\t\tcase 5:\n\t\t\tif (["8", "9", "a", "b"].indexOf(value.charAt(19)) === -1) {\n\t\t\t\t'+this.makeError({type:"uuid",actual:"value",messages:t})+"\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t"),{source:n.join("\n")}}function s(t){t=t.messages;var e=[];return e.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tif (!"+P.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"url",actual:"value",messages:t})+"\n\t\t}\n\n\t\treturn value;\n\t"),{source:e.join("\n")}}function i(t){var e=t.schema;t=t.messages;var n=[],r=!1;if(!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "string") {\n\t\t\t\tvalue = String(value);\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar origValue = value;\n\t"),e.trim&&(r=!0,n.push("\n\t\t\tvalue = value.trim();\n\t\t")),e.trimLeft&&(r=!0,n.push("\n\t\t\tvalue = value.trimLeft();\n\t\t")),e.trimRight&&(r=!0,n.push("\n\t\t\tvalue = value.trimRight();\n\t\t")),e.padStart&&(r=!0,n.push("\n\t\t\tvalue = value.padStart("+e.padStart+", "+JSON.stringify(null!=e.padChar?e.padChar:" ")+");\n\t\t")),e.padEnd&&(r=!0,n.push("\n\t\t\tvalue = value.padEnd("+e.padEnd+", "+JSON.stringify(null!=e.padChar?e.padChar:" ")+");\n\t\t")),e.lowercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLowerCase();\n\t\t")),e.uppercase&&(r=!0,n.push("\n\t\t\tvalue = value.toUpperCase();\n\t\t")),e.localeLowercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLocaleLowerCase();\n\t\t")),e.localeUppercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLocaleUpperCase();\n\t\t")),n.push("\n\t\t\tvar len = value.length;\n\t"),!1===e.empty&&n.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"stringEmpty",actual:"value",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.min&&n.push("\n\t\t\tif (len < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"stringMin",expected:e.min,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (len > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"stringMax",expected:e.max,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.length&&n.push("\n\t\t\tif (len !== "+e.length+") {\n\t\t\t\t"+this.makeError({type:"stringLength",expected:e.length,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.pattern){var a=e.pattern;"string"==typeof e.pattern&&(a=new RegExp(e.pattern,e.patternFlags)),n.push("\n\t\t\tif (!"+a.toString()+".test(value))\n\t\t\t\t"+this.makeError({type:"stringPattern",expected:'"'+a.toString().replace('"','\\"')+'"',actual:"origValue",messages:t})+"\n\t\t")}return null!=e.contains&&n.push('\n\t\t\tif (value.indexOf("'+e.contains+'") === -1) {\n\t\t\t\t'+this.makeError({type:"stringContains",expected:'"'+e.contains+'"',actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.enum&&(a=JSON.stringify(e.enum),n.push("\n\t\t\tif ("+a+".indexOf(value) === -1) {\n\t\t\t\t"+this.makeError({type:"stringEnum",expected:'"'+e.enum.join(", ")+'"',actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t")),!0===e.numeric&&n.push("\n\t\t\tif (!"+V.toString()+".test(value) ) {\n\t\t\t\t"+this.makeError({type:"stringNumeric",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alpha&&n.push("\n\t\t\tif(!"+M.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlpha",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alphanum&&n.push("\n\t\t\tif(!"+F.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlphanum",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alphadash&&n.push("\n\t\t\tif(!"+q.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlphadash",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.hex&&n.push("\n\t\t\tif(value.length % 2 !== 0 || !"+R.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringHex",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),n.push("\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function u(t,e,n){var r=t.schema;t=t.messages;var a=[];a.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"object",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t");var s=r.properties||r.props;if(s){a.push("var parentObj = value;"),a.push("var parentField = field;");for(var i=Object.keys(s),u=0;u<i.length;u++){var l=i[u],o=S(l),f=T.test(o)?"."+o:"['"+o+"']",c="parentObj"+f,p=(e?e+".":"")+l;a.push("\n// Field: "+S(p)),a.push('field = parentField ? parentField + "'+f+'" : "'+o+'";'),a.push("value = "+c+";"),l=this.getRuleFromSchema(s[l]),o="\n\t\t\t\t"+c+" = context.fn[%%INDEX%%](value, field, parentObj, errors, context);\n\t\t\t\t"+this.makeCustomValidator({vName:c,path:p,schema:l.schema,context:n,messages:t})+"\n\t\t\t",a.push(this.compileRule(l,n,p,o,c))}r.strict&&(e=Object.keys(s),a.push("\n\t\t\t\tfield = parentField;\n\t\t\t\tvar invalidProps = [];\n\t\t\t\tvar props = Object.keys(parentObj);\n\n\t\t\t\tfor (let i = 0; i < props.length; i++) {\n\t\t\t\t\tif ("+JSON.stringify(e)+".indexOf(props[i]) === -1) {\n\t\t\t\t\t\tinvalidProps.push(props[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (invalidProps.length) {\n\t\t\t"),"remove"==r.strict?a.push("\n\t\t\t\t\tinvalidProps.forEach(function(field) {\n\t\t\t\t\t\tdelete parentObj[field];\n\t\t\t\t\t});\n\t\t\t\t"):a.push("\n\t\t\t\t\t"+this.makeError({type:"objectStrict",expected:'"'+e.join(", ")+'"',actual:"invalidProps.join(', ')",messages:t})+"\n\t\t\t\t"),a.push("\n\t\t\t\t}\n\t\t\t")),a.push("\n\t\t\treturn parentObj;\n\t\t")}else a.push("\n\t\t\treturn value;\n\t\t");return{source:a.join("\n")}}function l(t){var e=t.schema;t=t.messages;var n=[];n.push("\n\t\tvar origValue = value;\n\t");var r=!1;return!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "number") {\n\t\t\t\tvalue = Number(value);\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "number" || isNaN(value) || !isFinite(value)) {\n\t\t\t'+this.makeError({type:"number",actual:"origValue",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t"),null!=e.min&&n.push("\n\t\t\tif (value < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"numberMin",expected:e.min,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (value > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"numberMax",expected:e.max,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.equal&&n.push("\n\t\t\tif (value !== "+e.equal+") {\n\t\t\t\t"+this.makeError({type:"numberEqual",expected:e.equal,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.notEqual&&n.push("\n\t\t\tif (value === "+e.notEqual+") {\n\t\t\t\t"+this.makeError({type:"numberNotEqual",expected:e.notEqual,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.integer&&n.push("\n\t\t\tif (value % 1 !== 0) {\n\t\t\t\t"+this.makeError({type:"numberInteger",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.positive&&n.push("\n\t\t\tif (value <= 0) {\n\t\t\t\t"+this.makeError({type:"numberPositive",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.negative&&n.push("\n\t\t\tif (value >= 0) {\n\t\t\t\t"+this.makeError({type:"numberNegative",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),n.push("\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function o(t,e,n){t=t.schema;var r=[];r.push("\n\t\tvar prevErrLen = errors.length;\n\t\tvar errBefore;\n\t\tvar hasValid = false;\n\t\tvar newVal = value;\n\t");for(var a=0;a<t.rules.length;a++){r.push("\n\t\t\tif (!hasValid) {\n\t\t\t\terrBefore = errors.length;\n\t\t");var s=this.getRuleFromSchema(t.rules[a]);r.push(this.compileRule(s,n,e,"var tmpVal = context.fn[%%INDEX%%](value, field, parent, errors, context);","tmpVal")),r.push("\n\t\t\t\tif (errors.length == errBefore) {\n\t\t\t\t\thasValid = true;\n\t\t\t\t\tnewVal = tmpVal;\n\t\t\t\t}\n\t\t\t}\n\t\t")}return r.push("\n\t\tif (hasValid) {\n\t\t\terrors.length = prevErrLen;\n\t\t}\n\t\t\n\t\treturn newVal;\n\t"),{source:r.join("\n")}}function f(t){return{source:'\n\t\t\tif (typeof value !== "function")\n\t\t\t\t'+this.makeError({type:"function",actual:"value",messages:t.messages})+"\n\n\t\t\treturn value;\n\t\t"}}function c(t){var e=t.schema;t=t.messages;var n=[];return n.push("\n\t\tif (value !== null && value !== undefined) {\n\t"),e.remove?n.push("\n\t\t\treturn undefined;\n\t\t"):n.push("\n\t\t\t"+this.makeError({type:"forbidden",actual:"value",messages:t})+"\n\t\t"),n.push("\n\t\t}\n\n\t\treturn value;\n\t"),{source:n.join("\n")}}function p(t){var e=t.schema;t=t.messages;var n=[];return e.field?(e.strict?n.push('\n\t\t\t\tif (value !== parent["'+e.field+'"])\n\t\t\t'):n.push('\n\t\t\t\tif (value != parent["'+e.field+'"])\n\t\t\t'),n.push("\n\t\t\t\t"+this.makeError({type:"equalField",actual:"value",expected:JSON.stringify(e.field),messages:t})+"\n\t\t")):(e.strict?n.push("\n\t\t\t\tif (value !== "+JSON.stringify(e.value)+")\n\t\t\t"):n.push("\n\t\t\t\tif (value != "+JSON.stringify(e.value)+")\n\t\t\t"),n.push("\n\t\t\t\t"+this.makeError({type:"equalValue",actual:"value",expected:JSON.stringify(e.value),messages:t})+"\n\t\t")),n.push("\n\t\treturn value;\n\t"),{source:n.join("\n")}}function h(t){var e=t.schema;return t=t.messages,{source:"\n\t\t\tif ("+JSON.stringify(e.values||[])+".indexOf(value) === -1)\n\t\t\t\t"+this.makeError({type:"enumValue",expected:'"'+e.values.join(", ")+'"',actual:"value",messages:t})+"\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function m(t){var e=t.schema;t=t.messages;var n=[],r="precise"==e.mode?C:A,a=!1;return n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t"),e.normalize&&(a=!0,n.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t")),n.push("\n\t\tif (!"+r.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"email",actual:"value",messages:t})+"\n\t\t}\n\n\t\treturn value;\n\t"),{sanitized:a,source:n.join("\n")}}function d(t){var e=t.schema;t=t.messages;var n=[],r=!1;return n.push("\n\t\tvar origValue = value;\n\t"),!0===e.convert&&(r=!0,n.push("\n\t\t\tif (!(value instanceof Date)) {\n\t\t\t\tvalue = new Date(value);\n\t\t\t}\n\t\t")),n.push("\n\t\tif (!(value instanceof Date) || isNaN(value.getTime()))\n\t\t\t"+this.makeError({type:"date",actual:"origValue",messages:t})+"\n\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function v(t,e,n){var r=[];return r.push("\n\t\t"+this.makeCustomValidator({fnName:"check",path:e,schema:t.schema,messages:t.messages,context:n})+"\n\t\treturn value;\n\t"),{source:r.join("\n")}}function g(t,e){var n=t.schema,r=[];return r.push('\n\t\tif (!(value instanceof context.customs["'+e+'"].schema.instanceOf))\n\t\t\t'+this.makeError({type:"classInstanceOf",actual:"value",expected:"'"+(n.instanceOf.name?n.instanceOf.name:"<UnknowClass>")+"'",messages:t.messages})+"\n\t"),r.push("\n\t\treturn value;\n\t"),{source:r.join("\n")}}function y(t){var e=t.schema;t=t.messages;var n=[],r=!1;return n.push("\n\t\tvar origValue = value;\n\t"),!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "boolean") {\n\t\t\t\tif (\n\t\t\t\tvalue === 1\n\t\t\t\t|| value === "true"\n\t\t\t\t|| value === "1"\n\t\t\t\t|| value === "on"\n\t\t\t\t) {\n\t\t\t\t\tvalue = true;\n\t\t\t\t} else if (\n\t\t\t\tvalue === 0\n\t\t\t\t|| value === "false"\n\t\t\t\t|| value === "0"\n\t\t\t\t|| value === "off"\n\t\t\t\t) {\n\t\t\t\t\tvalue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "boolean") {\n\t\t\t'+this.makeError({type:"boolean",actual:"origValue",messages:t})+"\n\t\t}\n\t\t\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function b(t,e,n){var r=t.schema,a=t.messages;if((t=[]).push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"array",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t"),!1===r.empty&&t.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"arrayEmpty",actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.min&&t.push("\n\t\t\tif (len < "+r.min+") {\n\t\t\t\t"+this.makeError({type:"arrayMin",expected:r.min,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.max&&t.push("\n\t\t\tif (len > "+r.max+") {\n\t\t\t\t"+this.makeError({type:"arrayMax",expected:r.max,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.length&&t.push("\n\t\t\tif (len !== "+r.length+") {\n\t\t\t\t"+this.makeError({type:"arrayLength",expected:r.length,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.contains&&t.push("\n\t\t\tif (value.indexOf("+JSON.stringify(r.contains)+") === -1) {\n\t\t\t\t"+this.makeError({type:"arrayContains",expected:JSON.stringify(r.contains),actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),!0===r.unique&&t.push("\n\t\t\tif(len > (new Set(value)).size) {\n\t\t\t\t"+this.makeError({type:"arrayUnique",expected:"Array.from(new Set(value.filter((item, index) => value.indexOf(item) !== index)))",actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.enum){var s=JSON.stringify(r.enum);t.push("\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tif ("+s+".indexOf(value[i]) === -1) {\n\t\t\t\t\t"+this.makeError({type:"arrayEnum",expected:'"'+r.enum.join(", ")+'"',actual:"value[i]",messages:a})+"\n\t\t\t\t}\n\t\t\t}\n\t\t")}return null!=r.items&&(t.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t"),r=this.getRuleFromSchema(r.items),a='\n\t\t\tarr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context);\n\t\t\t'+this.makeCustomValidator({vName:"arr[i]",path:e,schema:r.schema,context:n,messages:a})+"\n\t\t",t.push(this.compileRule(r,n,e,a,"arr[i]")),t.push("\n\t\t\t}\n\t\t")),t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function x(){return{}}function E(t,e,n){void 0===n&&(n={});for(var r in e){var a=e[r];(a="object"==typeof a&&!Array.isArray(a)&&null!=a&&0<Object.keys(a).length)?(t[r]=t[r]||{},E(t[r],e[r],n)):!0===n.skipIfExist&&void 0!==t[r]||(t[r]=e[r])}return t}function S(t){return t.replace(I,function(t){switch(t){case'"':case"'":case"\\":return"\\"+t;case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029"}})}function k(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}var O,j,w,_,N={required:"The '{field}' field is required.",string:"The '{field}' field must be a string.",stringEmpty:"The '{field}' field must not be empty.",stringMin:"The '{field}' field length must be greater than or equal to {expected} characters long.",stringMax:"The '{field}' field length must be less than or equal to {expected} characters long.",stringLength:"The '{field}' field length must be {expected} characters long.",stringPattern:"The '{field}' field fails to match the required pattern.",stringContains:"The '{field}' field must contain the '{expected}' text.",stringEnum:"The '{field}' field does not match any of the allowed values.",stringNumeric:"The '{field}' field must be a numeric string.",stringAlpha:"The '{field}' field must be an alphabetic string.",stringAlphanum:"The '{field}' field must be an alphanumeric string.",stringAlphadash:"The '{field}' field must be an alphadash string.",stringHex:"The '{field}' field must be a hex string.",number:"The '{field}' field must be a number.",numberMin:"The '{field}' field must be greater than or equal to {expected}.",numberMax:"The '{field}' field must be less than or equal to {expected}.",numberEqual:"The '{field}' field must be equal to {expected}.",numberNotEqual:"The '{field}' field can't be equal to {expected}.",numberInteger:"The '{field}' field must be an integer.",numberPositive:"The '{field}' field must be a positive number.",numberNegative:"The '{field}' field must be a negative number.",array:"The '{field}' field must be an array.",arrayEmpty:"The '{field}' field must not be an empty array.",arrayMin:"The '{field}' field must contain at least {expected} items.",arrayMax:"The '{field}' field must contain less than or equal to {expected} items.",arrayLength:"The '{field}' field must contain {expected} items.",arrayContains:"The '{field}' field must contain the '{expected}' item.",arrayUnique:"The '{actual}' value in '{field}' field does not unique the '{expected}' values.",arrayEnum:"The '{actual}' value in '{field}' field does not match any of the '{expected}' values.",boolean:"The '{field}' field must be a boolean.",date:"The '{field}' field must be a Date.",dateMin:"The '{field}' field must be greater than or equal to {expected}.",dateMax:"The '{field}' field must be less than or equal to {expected}.",enumValue:"The '{field}' field value '{expected}' does not match any of the allowed values.",equalValue:"The '{field}' field value must be equal to '{expected}'.",equalField:"The '{field}' field value must be equal to '{expected}' field value.",forbidden:"The '{field}' field is forbidden.",function:"The '{field}' field must be a function.",email:"The '{field}' field must be a valid e-mail.",luhn:"The '{field}' field must be a valid checksum luhn.",mac:"The '{field}' field must be a valid MAC address.",object:"The '{field}' must be an Object.",objectStrict:"The object '{field}' contains forbidden keys: '{actual}'.",url:"The '{field}' field must be a valid URL.",uuid:"The '{field}' field must be a valid UUID.",uuidVersion:"The '{field}' field must be a valid UUID version provided.",classInstanceOf:"The '{field}' field must be an instance of the '{expected}' class."},C=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,A=/^\S+@\S+\.\S+$/,T=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/,I=/["'\\\n\r\u2028\u2029]/g,V=/^-?[0-9]\d*(\.\d+)?$/,M=/^[a-zA-Z]+$/,F=/^[a-zA-Z0-9]+$/,q=/^[a-zA-Z0-9_-]+$/,R=/^[0-9a-fA-F]+$/,P=/^https?:\/\/\S+/,$=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/i,L=/^((([a-f0-9][a-f0-9]+[-]){5}|([a-f0-9][a-f0-9]+[:]){5})([a-f0-9][a-f0-9])$)|(^([a-f0-9][a-f0-9][a-f0-9][a-f0-9]+[.]){2}([a-f0-9][a-f0-9][a-f0-9][a-f0-9]))$/i;return t.prototype.validate=function(t,e){return this.compile(e)(t)},t.prototype.wrapRequiredCheckSourceCode=function(t,e,n){var r=[],a=null!=t.schema.default?JSON.stringify(t.schema.default):null;return r.push("\n\t\t\tif (value === undefined || value === null) {\n\t\t"),!0===t.schema.optional||"forbidden"==t.schema.type?null!=a&&n?r.push(n+" = "+a+";"):r.push("// Do nothing, it's an optional field"):null!=a&&n?r.push(n+" = "+a+";"):r.push(this.makeError({type:"required",actual:"value",messages:t.messages})),r.push("} else {"),e&&r.push(e),r.push("\t\t}"),r.join("\n")},t.prototype.compile=function(t){if(null===t||"object"!=typeof t)throw Error("Invalid schema.");var n=this,r={index:0,rules:[],fn:[],customs:{}};if(this.cache.clear(),!0!==t.$$root)if(Array.isArray(t))t=this.getRuleFromSchema(t).schema;else{var a=Object.assign({},t);t={type:"object",strict:a.$$strict,properties:a},delete a.$$strict}a=["var errors = [];","var field;"],t=this.getRuleFromSchema(t),a.push(this.compileRule(t,r,null,"context.fn[%%INDEX%%](value, field, null, errors, context);","value")),a.push("if (errors.length) {"),a.push('\n\t\t\treturn errors.map(err => {\n\t\t\t\tif (err.message)\n\t\t\t\t\terr.message = err.message\n\t\t\t\t\t\t.replace(/\\{field\\}/g, err.field || "")\n\t\t\t\t\t\t.replace(/\\{expected\\}/g, err.expected != null ? err.expected : "")\n\t\t\t\t\t\t.replace(/\\{actual\\}/g, err.actual != null ? err.actual : "");\n\n\t\t\t\treturn err;\n\t\t\t});\n\t\t'),a.push("}"),a.push("return true;"),t=a.join("\n");var s=new Function("value","context",t);if(this.opts.debug){var i=function(t){return t};"undefined"==typeof window&&(i=e),r.fn.forEach(function(t,e){return console.log(i("// Context.fn["+e+"]\n"+t.toString()))}),console.log(i("// Main check function\n"+s.toString()))}return this.cache.clear(),function(t){return r.data=t,s.call(n,t,r)}},t.prototype.compileRule=function(t,e,n,r,a){var s=[],i=this.cache.get(t.schema);return i?(t=i,t.cycle=!0,t.cycleStack=[],s.push(this.wrapRequiredCheckSourceCode(t,"\n\t\t\t\tvar rule = context.rules["+t.index+"];\n\t\t\t\tif (rule.cycleStack.indexOf(value) === -1) {\n\t\t\t\t\trule.cycleStack.push(value);\n\t\t\t\t\t"+r.replace("%%INDEX%%",t.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",a))):(this.cache.set(t.schema,t),t.index=e.index,e.rules[e.index]=t,e.customs[n]?e.customs[n].schema=t.schema:e.customs[n]={schema:t.schema},e.index++,n=t.ruleFunction.call(this,t,n,e),n.source?(n=new Function("value","field","parent","errors","context",n.source),e.fn[t.index]=n,s.push(this.wrapRequiredCheckSourceCode(t,r.replace("%%INDEX%%",t.index),a))):s.push(this.wrapRequiredCheckSourceCode(t))),s.join("\n")},t.prototype.getRuleFromSchema=function(t){var e=this;if("string"==typeof t){var n=t.split("|").map(function(t){return t.trim()});t={type:n[0]},n.slice(1).map(function(e){var n=e.indexOf(":");if(-1!==n){var r=e.substr(0,n).trim();"true"===(e=e.substr(n+1).trim())||"false"===e?e="true"===e:Number.isNaN(Number(e))||(e=Number(e)),t[r]=e}else e.startsWith("no-")?t[e.slice(3)]=!1:t[e]=!0})}else if(Array.isArray(t)){if(0==t.length)throw Error("Invalid schema.");(t={type:"multi",rules:t}).rules.map(function(t){return e.getRuleFromSchema(t)}).every(function(t){return 1==t.schema.optional})&&(t.optional=!0)}if((n=this.aliases[t.type])&&(delete t.type,t=E(t,n,{skipIfExist:!0})),!(n=this.rules[t.type]))throw Error("Invalid '"+t.type+"' type in validator schema.");return{messages:Object.assign({},this.messages,t.messages),schema:E(t,this.defaults[t.type],{skipIfExist:!0}),ruleFunction:n}},t.prototype.makeError=function(t){var e=t.type,n=t.field,r=t.expected,a=t.actual,s={type:'"'+e+'"',message:'"'+t.messages[e]+'"'};return s.field=n?'"'+n+'"':"field",r&&(s.expected=r),a&&(s.actual=a),"errors.push({ "+Object.keys(s).map(function(t){return t+": "+s[t]}).join(", ")+" });"},t.prototype.makeCustomValidator=function(t){var e=t.vName;void 0===e&&(e="value");var n=t.fnName;void 0===n&&(n="custom");var r=t.path,a=t.context,s=t.messages;return"function"==typeof t.schema[n]?(a.customs[r]?a.customs[r].messages=s:a.customs[r]={messages:s},this.opts.useNewCustomCheckerFunction?'\n\t\t\t\t\tconst rule = context.customs["'+r+'"];\n\t\t\t\t\tconst fnCustomErrors = [];\n\t\t\t\t\t'+e+" = rule.schema."+n+".call(this, "+e+', fnCustomErrors, rule.schema, "'+r+'", parent, context);\n\t\t\t\t\tif (Array.isArray(fnCustomErrors)) {\n\t\t\t\t\tfnCustomErrors.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t':'\n\t\t\t\tconst rule = context.customs["'+r+'"];\n\t\t\t\tconst res = rule.schema.'+n+".call(this, "+e+', rule.schema, "'+r+'", parent, context);\n\t\t\t\tif (Array.isArray(res)) {\n\t\t\t\t\tres.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t'):""},t.prototype.add=function(t,e){this.rules[t]=e},t.prototype.alias=function(t,e){if(this.rules[t])throw Error("Alias name must not be a rule name");this.aliases[t]=e},t}var f=f||{};f.scope={},f.arrayIteratorImpl=function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}},f.arrayIterator=function(t){return{next:f.arrayIteratorImpl(t)}},f.ASSUME_ES5=!1,f.ASSUME_NO_NATIVE_MAP=!1,f.ASSUME_NO_NATIVE_SET=!1,f.SIMPLE_FROUND_POLYFILL=!1,f.defineProperty=f.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)},f.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,t];for(var e=0;e<t.length;++e){var n=t[e];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")},f.global=f.getGlobal(this),f.SYMBOL_PREFIX="jscomp_symbol_",f.initSymbol=function(){f.initSymbol=function(){},f.global.Symbol||(f.global.Symbol=f.Symbol)},f.SymbolClass=function(t,e){this.$jscomp$symbol$id_=t,f.defineProperty(this,"description",{configurable:!0,writable:!0,value:e})},f.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_},f.Symbol=function(){function t(n){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new f.SymbolClass(f.SYMBOL_PREFIX+(n||"")+"_"+e++,n)}var e=0;return t}(),f.initSymbolIterator=function(){f.initSymbol();var t=f.global.Symbol.iterator;t||(t=f.global.Symbol.iterator=f.global.Symbol("Symbol.iterator")),"function"!=typeof Array.prototype[t]&&f.defineProperty(Array.prototype,t,{configurable:!0,writable:!0,value:function(){return f.iteratorPrototype(f.arrayIteratorImpl(this))}}),f.initSymbolIterator=function(){}},f.initSymbolAsyncIterator=function(){f.initSymbol();var t=f.global.Symbol.asyncIterator;t||(t=f.global.Symbol.asyncIterator=f.global.Symbol("Symbol.asyncIterator")),f.initSymbolAsyncIterator=function(){}},f.iteratorPrototype=function(t){return f.initSymbolIterator(),t={next:t},t[f.global.Symbol.iterator]=function(){return this},t},f.iteratorFromArray=function(t,e){f.initSymbolIterator(),t instanceof String&&(t+="");var n=0,r={next:function(){if(n<t.length){var a=n++;return{value:e(a,t[a]),done:!1}}return r.next=function(){return{done:!0,value:void 0}},r.next()}};return r[Symbol.iterator]=function(){return r},r},f.polyfill=function(t,e){if(e){var n=f.global;t=t.split(".");for(var r=0;r<t.length-1;r++){var a=t[r];a in n||(n[a]={}),n=n[a]}(e=e(r=n[t=t[t.length-1]]))!=r&&null!=e&&f.defineProperty(n,t,{configurable:!0,writable:!0,value:e})}},f.polyfill("Array.prototype.keys",function(t){return t||function(){return f.iteratorFromArray(this,function(t){return t})}},"es6","es3"),f.polyfill("Array.prototype.values",function(t){return t||function(){return f.iteratorFromArray(this,function(t,e){return e})}},"es8","es3"),f.checkEs6ConformanceViaProxy=function(){try{var t={},e=Object.create(new f.global.Proxy(t,{get:function(n,r,a){return n==t&&"q"==r&&a==e}}));return!0===e.q}catch(t){return!1}},f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,f.ES6_CONFORMANCE=f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&f.checkEs6ConformanceViaProxy(),f.makeIterator=function(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):f.arrayIterator(t)},f.owns=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},f.polyfill("WeakMap",function(t){function e(t){if(this.id_=(u+=Math.random()+1).toString(),t){t=f.makeIterator(t);for(var e;!(e=t.next()).done;)e=e.value,this.set(e[0],e[1])}}function n(){}function r(t){var e=typeof t;return"object"===e&&null!==t||"function"===e}function a(t){if(!f.owns(t,i)){var e=new n;f.defineProperty(t,i,{value:e})}}function s(t){var e=Object[t];e&&(Object[t]=function(t){return t instanceof n?t:(a(t),e(t))})}if(f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&f.ES6_CONFORMANCE)return t}else if(function(){if(!t||!Object.seal)return!1;try{var e=Object.seal({}),n=Object.seal({}),r=new t([[e,2],[n,3]]);return 2==r.get(e)&&3==r.get(n)&&(r.delete(e),r.set(n,4),!r.has(e)&&4==r.get(n))}catch(t){return!1}}())return t;var i="$jscomp_hidden_"+Math.random();s("freeze"),s("preventExtensions"),s("seal");var u=0;return e.prototype.set=function(t,e){if(!r(t))throw Error("Invalid WeakMap key");if(a(t),!f.owns(t,i))throw Error("WeakMap key fail: "+t);return t[i][this.id_]=e,this},e.prototype.get=function(t){return r(t)&&f.owns(t,i)?t[i][this.id_]:void 0},e.prototype.has=function(t){return r(t)&&f.owns(t,i)&&f.owns(t[i],this.id_)},e.prototype.delete=function(t){return!!(r(t)&&f.owns(t,i)&&f.owns(t[i],this.id_))&&delete t[i][this.id_]},e},"es6","es3"),f.MapEntry=function(){},f.polyfill("Map",function(t){function e(){var t={};return t.previous=t.next=t.head=t}function n(t,e){var n=t.head_;return f.iteratorPrototype(function(){if(n){for(;n.head!=t.head_;)n=n.previous;for(;n.next!=n.head;)return n=n.next,{done:!1,value:e(n)};n=null}return{done:!0,value:void 0}})}function r(t,e){var n=e&&typeof e;"object"==n||"function"==n?s.has(e)?n=s.get(e):(n=""+ ++i,s.set(e,n)):n="p_"+e;var r=t.data_[n];if(r&&f.owns(t.data_,n))for(t=0;t<r.length;t++){var a=r[t];if(e!==e&&a.key!==a.key||e===a.key)return{id:n,list:r,index:t,entry:a}}return{id:n,list:r,index:-1,entry:void 0}}function a(t){if(this.data_={},this.head_=e(),this.size=0,t){t=f.makeIterator(t);for(var n;!(n=t.next()).done;)n=n.value,this.set(n[0],n[1])}}if(f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&f.ES6_CONFORMANCE)return t}else if(function(){if(f.ASSUME_NO_NATIVE_MAP||!t||"function"!=typeof t||!t.prototype.entries||"function"!=typeof Object.seal)return!1;try{var e=Object.seal({x:4}),n=new t(f.makeIterator([[e,"s"]]));if("s"!=n.get(e)||1!=n.size||n.get({x:4})||n.set({x:4},"t")!=n||2!=n.size)return!1;var r=n.entries(),a=r.next();return!a.done&&a.value[0]==e&&"s"==a.value[1]&&!((a=r.next()).done||4!=a.value[0].x||"t"!=a.value[1]||!r.next().done)}catch(t){return!1}}())return t;f.initSymbolIterator();var s=new WeakMap;a.prototype.set=function(t,e){var n=r(this,t=0===t?0:t);return n.list||(n.list=this.data_[n.id]=[]),n.entry?n.entry.value=e:(n.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:t,value:e},n.list.push(n.entry),this.head_.previous.next=n.entry,this.head_.previous=n.entry,this.size++),this},a.prototype.delete=function(t){return!(!(t=r(this,t)).entry||!t.list)&&(t.list.splice(t.index,1),t.list.length||delete this.data_[t.id],t.entry.previous.next=t.entry.next,t.entry.next.previous=t.entry.previous,t.entry.head=null,this.size--,!0)},a.prototype.clear=function(){this.data_={},this.head_=this.head_.previous=e(),this.size=0},a.prototype.has=function(t){return!!r(this,t).entry},a.prototype.get=function(t){return(t=r(this,t).entry)&&t.value},a.prototype.entries=function(){return n(this,function(t){return[t.key,t.value]})},a.prototype.keys=function(){return n(this,function(t){return t.key})},a.prototype.values=function(){return n(this,function(t){return t.value})},a.prototype.forEach=function(t,e){for(var n,r=this.entries();!(n=r.next()).done;)n=n.value,t.call(e,n[1],n[0],this)},a.prototype[Symbol.iterator]=a.prototype.entries;var i=0;return a},"es6","es3"),f.assign="function"==typeof Object.assign?Object.assign:function(t,e){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var a in r)f.owns(r,a)&&(t[a]=r[a])}return t},f.polyfill("Object.assign",function(t){return t||f.assign},"es6","es3"),f.polyfill("Number.isNaN",function(t){return t||function(t){return"number"==typeof t&&isNaN(t)}},"es6","es3"),f.checkStringArgs=function(t,e,n){if(null==t)throw new TypeError("The 'this' value for String.prototype."+n+" must not be null or undefined");if(e instanceof RegExp)throw new TypeError("First argument to String.prototype."+n+" must not be a regular expression");return t+""},f.polyfill("String.prototype.startsWith",function(t){return t||function(t,e){var n=f.checkStringArgs(this,t,"startsWith");t+="";var r=n.length,a=t.length;e=Math.max(0,Math.min(0|e,n.length));for(var s=0;s<a&&e<r;)if(n[e++]!=t[s++])return!1;return s>=a}},"es6","es3");var v=this;"object"==typeof exports&&"undefined"!=typeof module?module.exports=w():"function"==typeof define&&define.amd?define(w):(v=v||self,v.FastestValidator=w());
"use strict";function w(){function t(t){this.opts={messages:E({},N)},this.defaults={},t&&(E(this.opts,t),t.defaults&&E(this.defaults,t.defaults)),this.messages=this.opts.messages,this.rules={any:x,array:b,boolean:y,class:g,custom:v,date:d,email:m,enum:h,equal:p,forbidden:c,function:f,multi:o,number:l,object:u,string:i,url:s,uuid:a,mac:r,luhn:n},this.aliases={},this.cache=new Map}function e(t){return O||(O=k(),j={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},w=k(),_={language:"js",theme:w.fromJson({keyword:["white","bold"],built_in:"magenta",literal:"cyan",number:"magenta",regexp:"red",string:["yellow","bold"],symbol:"plain",class:"blue",attr:"plain",function:["white","bold"],title:"plain",params:"green",comment:"grey"})}),t=O.format(t,j),w.highlight(t,_)}function n(t){return t=t.messages,{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+'\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (typeof value !== "string")\n\t\t\t\tvalue = String(value);\n\n\t\t\tval = value.replace(/\\D+/g, "");\n\n\t\t\tvar array = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9];\n\t\t\tvar len = val ? val.length : 0,\n\t\t\t\tbit = 1,\n\t\t\t\tsum = 0;\n\t\t\twhile (len--) {\n\t\t\t\tsum += !(bit ^= 1) ? parseInt(val[len], 10) : array[val[len]];\n\t\t\t}\n\n\t\t\tif (!(sum % 10 === 0 && sum > 0)) {\n\t\t\t\t'+this.makeError({type:"luhn",actual:"value",messages:t})+"\n\t\t\t}\n\n\t\t\treturn value;\n\t\t"}}function r(t){return t=t.messages,{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tvar v = value.toLowerCase();\n\t\t\tif (!"+L.toString()+".test(v)) {\n\t\t\t\t"+this.makeError({type:"mac",actual:"value",messages:t})+"\n\t\t\t}\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function a(t){var e=t.schema;t=t.messages;var n=[];return n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar val = value.toLowerCase();\n\t\tif (!"+$.toString()+".test(val)) {\n\t\t\t"+this.makeError({type:"uuid",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tconst version = val.charAt(14) | 0;\n\t"),e.version&&n.push("\n\t\t\tif ("+e.version+" !== version) {\n\t\t\t\t"+this.makeError({type:"uuidVersion",expected:e.version,actual:"version",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),n.push('\n\t\tswitch (version) {\n\t\tcase 1:\n\t\tcase 2:\n\t\t\tbreak;\n\t\tcase 3:\n\t\tcase 4:\n\t\tcase 5:\n\t\t\tif (["8", "9", "a", "b"].indexOf(value.charAt(19)) === -1) {\n\t\t\t\t'+this.makeError({type:"uuid",actual:"value",messages:t})+"\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t"),{source:n.join("\n")}}function s(t){t=t.messages;var e=[];return e.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tif (!"+P.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"url",actual:"value",messages:t})+"\n\t\t}\n\n\t\treturn value;\n\t"),{source:e.join("\n")}}function i(t){var e=t.schema;t=t.messages;var n=[],r=!1;if(!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "string") {\n\t\t\t\tvalue = String(value);\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar origValue = value;\n\t"),e.trim&&(r=!0,n.push("\n\t\t\tvalue = value.trim();\n\t\t")),e.trimLeft&&(r=!0,n.push("\n\t\t\tvalue = value.trimLeft();\n\t\t")),e.trimRight&&(r=!0,n.push("\n\t\t\tvalue = value.trimRight();\n\t\t")),e.padStart&&(r=!0,n.push("\n\t\t\tvalue = value.padStart("+e.padStart+", "+JSON.stringify(null!=e.padChar?e.padChar:" ")+");\n\t\t")),e.padEnd&&(r=!0,n.push("\n\t\t\tvalue = value.padEnd("+e.padEnd+", "+JSON.stringify(null!=e.padChar?e.padChar:" ")+");\n\t\t")),e.lowercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLowerCase();\n\t\t")),e.uppercase&&(r=!0,n.push("\n\t\t\tvalue = value.toUpperCase();\n\t\t")),e.localeLowercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLocaleLowerCase();\n\t\t")),e.localeUppercase&&(r=!0,n.push("\n\t\t\tvalue = value.toLocaleUpperCase();\n\t\t")),n.push("\n\t\t\tvar len = value.length;\n\t"),!1===e.empty&&n.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"stringEmpty",actual:"value",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.min&&n.push("\n\t\t\tif (len < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"stringMin",expected:e.min,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (len > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"stringMax",expected:e.max,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.length&&n.push("\n\t\t\tif (len !== "+e.length+") {\n\t\t\t\t"+this.makeError({type:"stringLength",expected:e.length,actual:"len",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.pattern){var a=e.pattern;"string"==typeof e.pattern&&(a=new RegExp(e.pattern,e.patternFlags)),n.push("\n\t\t\tif (!"+a.toString()+".test(value))\n\t\t\t\t"+this.makeError({type:"stringPattern",expected:'"'+a.toString().replace('"','\\"')+'"',actual:"origValue",messages:t})+"\n\t\t")}return null!=e.contains&&n.push('\n\t\t\tif (value.indexOf("'+e.contains+'") === -1) {\n\t\t\t\t'+this.makeError({type:"stringContains",expected:'"'+e.contains+'"',actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.enum&&(a=JSON.stringify(e.enum),n.push("\n\t\t\tif ("+a+".indexOf(value) === -1) {\n\t\t\t\t"+this.makeError({type:"stringEnum",expected:'"'+e.enum.join(", ")+'"',actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t")),!0===e.numeric&&n.push("\n\t\t\tif (!"+V.toString()+".test(value) ) {\n\t\t\t\t"+this.makeError({type:"stringNumeric",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alpha&&n.push("\n\t\t\tif(!"+M.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlpha",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alphanum&&n.push("\n\t\t\tif(!"+F.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlphanum",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.alphadash&&n.push("\n\t\t\tif(!"+q.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlphadash",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.hex&&n.push("\n\t\t\tif(value.length % 2 !== 0 || !"+R.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringHex",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),n.push("\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function u(t,e,n){var r=t.schema;t=t.messages;var a=[];a.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"object",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t");var s=r.properties||r.props;if(s){a.push("var parentObj = value;"),a.push("var parentField = field;");for(var i=Object.keys(s),u=0;u<i.length;u++){var l=i[u],o=S(l),f=T.test(o)?"."+o:"['"+o+"']",c="parentObj"+f,p=(e?e+".":"")+l;a.push("\n// Field: "+S(p)),a.push('field = parentField ? parentField + "'+f+'" : "'+o+'";'),a.push("value = "+c+";"),l=this.getRuleFromSchema(s[l]),o="\n\t\t\t\t"+c+" = context.fn[%%INDEX%%](value, field, parentObj, errors, context);\n\t\t\t\t"+this.makeCustomValidator({vName:c,path:p,schema:l.schema,context:n,messages:t})+"\n\t\t\t",a.push(this.compileRule(l,n,p,o,c))}r.strict&&(e=Object.keys(s),a.push("\n\t\t\t\tfield = parentField;\n\t\t\t\tvar invalidProps = [];\n\t\t\t\tvar props = Object.keys(parentObj);\n\n\t\t\t\tfor (let i = 0; i < props.length; i++) {\n\t\t\t\t\tif ("+JSON.stringify(e)+".indexOf(props[i]) === -1) {\n\t\t\t\t\t\tinvalidProps.push(props[i]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (invalidProps.length) {\n\t\t\t"),"remove"==r.strict?a.push("\n\t\t\t\t\tinvalidProps.forEach(function(field) {\n\t\t\t\t\t\tdelete parentObj[field];\n\t\t\t\t\t});\n\t\t\t\t"):a.push("\n\t\t\t\t\t"+this.makeError({type:"objectStrict",expected:'"'+e.join(", ")+'"',actual:"invalidProps.join(', ')",messages:t})+"\n\t\t\t\t"),a.push("\n\t\t\t\t}\n\t\t\t")),a.push("\n\t\t\treturn parentObj;\n\t\t")}else a.push("\n\t\t\treturn value;\n\t\t");return{source:a.join("\n")}}function l(t){var e=t.schema;t=t.messages;var n=[];n.push("\n\t\tvar origValue = value;\n\t");var r=!1;return!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "number") {\n\t\t\t\tvalue = Number(value);\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "number" || isNaN(value) || !isFinite(value)) {\n\t\t\t'+this.makeError({type:"number",actual:"origValue",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t"),null!=e.min&&n.push("\n\t\t\tif (value < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"numberMin",expected:e.min,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (value > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"numberMax",expected:e.max,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.equal&&n.push("\n\t\t\tif (value !== "+e.equal+") {\n\t\t\t\t"+this.makeError({type:"numberEqual",expected:e.equal,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.notEqual&&n.push("\n\t\t\tif (value === "+e.notEqual+") {\n\t\t\t\t"+this.makeError({type:"numberNotEqual",expected:e.notEqual,actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.integer&&n.push("\n\t\t\tif (value % 1 !== 0) {\n\t\t\t\t"+this.makeError({type:"numberInteger",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.positive&&n.push("\n\t\t\tif (value <= 0) {\n\t\t\t\t"+this.makeError({type:"numberPositive",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.negative&&n.push("\n\t\t\tif (value >= 0) {\n\t\t\t\t"+this.makeError({type:"numberNegative",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),n.push("\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function o(t,e,n){t=t.schema;var r=[];r.push("\n\t\tvar prevErrLen = errors.length;\n\t\tvar errBefore;\n\t\tvar hasValid = false;\n\t\tvar newVal = value;\n\t");for(var a=0;a<t.rules.length;a++){r.push("\n\t\t\tif (!hasValid) {\n\t\t\t\terrBefore = errors.length;\n\t\t");var s=this.getRuleFromSchema(t.rules[a]);r.push(this.compileRule(s,n,e,"var tmpVal = context.fn[%%INDEX%%](value, field, parent, errors, context);","tmpVal")),r.push("\n\t\t\t\tif (errors.length == errBefore) {\n\t\t\t\t\thasValid = true;\n\t\t\t\t\tnewVal = tmpVal;\n\t\t\t\t}\n\t\t\t}\n\t\t")}return r.push("\n\t\tif (hasValid) {\n\t\t\terrors.length = prevErrLen;\n\t\t}\n\t\t\n\t\treturn newVal;\n\t"),{source:r.join("\n")}}function f(t){return{source:'\n\t\t\tif (typeof value !== "function")\n\t\t\t\t'+this.makeError({type:"function",actual:"value",messages:t.messages})+"\n\n\t\t\treturn value;\n\t\t"}}function c(t){var e=t.schema;t=t.messages;var n=[];return n.push("\n\t\tif (value !== null && value !== undefined) {\n\t"),e.remove?n.push("\n\t\t\treturn undefined;\n\t\t"):n.push("\n\t\t\t"+this.makeError({type:"forbidden",actual:"value",messages:t})+"\n\t\t"),n.push("\n\t\t}\n\n\t\treturn value;\n\t"),{source:n.join("\n")}}function p(t){var e=t.schema;t=t.messages;var n=[];return e.field?(e.strict?n.push('\n\t\t\t\tif (value !== parent["'+e.field+'"])\n\t\t\t'):n.push('\n\t\t\t\tif (value != parent["'+e.field+'"])\n\t\t\t'),n.push("\n\t\t\t\t"+this.makeError({type:"equalField",actual:"value",expected:JSON.stringify(e.field),messages:t})+"\n\t\t")):(e.strict?n.push("\n\t\t\t\tif (value !== "+JSON.stringify(e.value)+")\n\t\t\t"):n.push("\n\t\t\t\tif (value != "+JSON.stringify(e.value)+")\n\t\t\t"),n.push("\n\t\t\t\t"+this.makeError({type:"equalValue",actual:"value",expected:JSON.stringify(e.value),messages:t})+"\n\t\t")),n.push("\n\t\treturn value;\n\t"),{source:n.join("\n")}}function h(t){var e=t.schema;return t=t.messages,{source:"\n\t\t\tif ("+JSON.stringify(e.values||[])+".indexOf(value) === -1)\n\t\t\t\t"+this.makeError({type:"enumValue",expected:'"'+e.values.join(", ")+'"',actual:"value",messages:t})+"\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function m(t){var e=t.schema;t=t.messages;var n=[],r="precise"==e.mode?C:A,a=!1;return n.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\t"),e.normalize&&(a=!0,n.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t")),n.push("\n\t\tif (!"+r.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"email",actual:"value",messages:t})+"\n\t\t}\n\n\t\treturn value;\n\t"),{sanitized:a,source:n.join("\n")}}function d(t){var e=t.schema;t=t.messages;var n=[],r=!1;return n.push("\n\t\tvar origValue = value;\n\t"),!0===e.convert&&(r=!0,n.push("\n\t\t\tif (!(value instanceof Date)) {\n\t\t\t\tvalue = new Date(value);\n\t\t\t}\n\t\t")),n.push("\n\t\tif (!(value instanceof Date) || isNaN(value.getTime()))\n\t\t\t"+this.makeError({type:"date",actual:"origValue",messages:t})+"\n\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function v(t,e,n){var r=[];return r.push("\n\t\t"+this.makeCustomValidator({fnName:"check",path:e,schema:t.schema,messages:t.messages,context:n})+"\n\t\treturn value;\n\t"),{source:r.join("\n")}}function g(t,e){var n=t.schema,r=[];return r.push('\n\t\tif (!(value instanceof context.customs["'+e+'"].schema.instanceOf))\n\t\t\t'+this.makeError({type:"classInstanceOf",actual:"value",expected:"'"+(n.instanceOf.name?n.instanceOf.name:"<UnknowClass>")+"'",messages:t.messages})+"\n\t"),r.push("\n\t\treturn value;\n\t"),{source:r.join("\n")}}function y(t){var e=t.schema;t=t.messages;var n=[],r=!1;return n.push("\n\t\tvar origValue = value;\n\t"),!0===e.convert&&(r=!0,n.push('\n\t\t\tif (typeof value !== "boolean") {\n\t\t\t\tif (\n\t\t\t\tvalue === 1\n\t\t\t\t|| value === "true"\n\t\t\t\t|| value === "1"\n\t\t\t\t|| value === "on"\n\t\t\t\t) {\n\t\t\t\t\tvalue = true;\n\t\t\t\t} else if (\n\t\t\t\tvalue === 0\n\t\t\t\t|| value === "false"\n\t\t\t\t|| value === "0"\n\t\t\t\t|| value === "off"\n\t\t\t\t) {\n\t\t\t\t\tvalue = false;\n\t\t\t\t}\n\t\t\t}\n\t\t')),n.push('\n\t\tif (typeof value !== "boolean") {\n\t\t\t'+this.makeError({type:"boolean",actual:"origValue",messages:t})+"\n\t\t}\n\t\t\n\t\treturn value;\n\t"),{sanitized:r,source:n.join("\n")}}function b(t,e,n){var r=t.schema,a=t.messages;if((t=[]).push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"array",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t"),!1===r.empty&&t.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"arrayEmpty",actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.min&&t.push("\n\t\t\tif (len < "+r.min+") {\n\t\t\t\t"+this.makeError({type:"arrayMin",expected:r.min,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.max&&t.push("\n\t\t\tif (len > "+r.max+") {\n\t\t\t\t"+this.makeError({type:"arrayMax",expected:r.max,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.length&&t.push("\n\t\t\tif (len !== "+r.length+") {\n\t\t\t\t"+this.makeError({type:"arrayLength",expected:r.length,actual:"len",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.contains&&t.push("\n\t\t\tif (value.indexOf("+JSON.stringify(r.contains)+") === -1) {\n\t\t\t\t"+this.makeError({type:"arrayContains",expected:JSON.stringify(r.contains),actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),!0===r.unique&&t.push("\n\t\t\tif(len > (new Set(value)).size) {\n\t\t\t\t"+this.makeError({type:"arrayUnique",expected:"Array.from(new Set(value.filter((item, index) => value.indexOf(item) !== index)))",actual:"value",messages:a})+"\n\t\t\t}\n\t\t"),null!=r.enum){var s=JSON.stringify(r.enum);t.push("\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tif ("+s+".indexOf(value[i]) === -1) {\n\t\t\t\t\t"+this.makeError({type:"arrayEnum",expected:'"'+r.enum.join(", ")+'"',actual:"value[i]",messages:a})+"\n\t\t\t\t}\n\t\t\t}\n\t\t")}return null!=r.items&&(t.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t\tfor (var i = 0; i < arr.length; i++) {\n\t\t"),e+="[]",r=this.getRuleFromSchema(r.items),a='\n\t\t\tarr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context);\n\t\t\t'+this.makeCustomValidator({vName:"arr[i]",path:e,schema:r.schema,context:n,messages:a})+"\n\t\t",t.push(this.compileRule(r,n,e,a,"arr[i]")),t.push("\n\t\t\t}\n\t\t")),t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function x(){return{}}function E(t,e,n){void 0===n&&(n={});for(var r in e){var a=e[r];(a="object"==typeof a&&!Array.isArray(a)&&null!=a&&0<Object.keys(a).length)?(t[r]=t[r]||{},E(t[r],e[r],n)):!0===n.skipIfExist&&void 0!==t[r]||(t[r]=e[r])}return t}function S(t){return t.replace(I,function(t){switch(t){case'"':case"'":case"\\":return"\\"+t;case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029"}})}function k(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}var O,j,w,_,N={required:"The '{field}' field is required.",string:"The '{field}' field must be a string.",stringEmpty:"The '{field}' field must not be empty.",stringMin:"The '{field}' field length must be greater than or equal to {expected} characters long.",stringMax:"The '{field}' field length must be less than or equal to {expected} characters long.",stringLength:"The '{field}' field length must be {expected} characters long.",stringPattern:"The '{field}' field fails to match the required pattern.",stringContains:"The '{field}' field must contain the '{expected}' text.",stringEnum:"The '{field}' field does not match any of the allowed values.",stringNumeric:"The '{field}' field must be a numeric string.",stringAlpha:"The '{field}' field must be an alphabetic string.",stringAlphanum:"The '{field}' field must be an alphanumeric string.",stringAlphadash:"The '{field}' field must be an alphadash string.",stringHex:"The '{field}' field must be a hex string.",number:"The '{field}' field must be a number.",numberMin:"The '{field}' field must be greater than or equal to {expected}.",numberMax:"The '{field}' field must be less than or equal to {expected}.",numberEqual:"The '{field}' field must be equal to {expected}.",numberNotEqual:"The '{field}' field can't be equal to {expected}.",numberInteger:"The '{field}' field must be an integer.",numberPositive:"The '{field}' field must be a positive number.",numberNegative:"The '{field}' field must be a negative number.",array:"The '{field}' field must be an array.",arrayEmpty:"The '{field}' field must not be an empty array.",arrayMin:"The '{field}' field must contain at least {expected} items.",arrayMax:"The '{field}' field must contain less than or equal to {expected} items.",arrayLength:"The '{field}' field must contain {expected} items.",arrayContains:"The '{field}' field must contain the '{expected}' item.",arrayUnique:"The '{actual}' value in '{field}' field does not unique the '{expected}' values.",arrayEnum:"The '{actual}' value in '{field}' field does not match any of the '{expected}' values.",boolean:"The '{field}' field must be a boolean.",date:"The '{field}' field must be a Date.",dateMin:"The '{field}' field must be greater than or equal to {expected}.",dateMax:"The '{field}' field must be less than or equal to {expected}.",enumValue:"The '{field}' field value '{expected}' does not match any of the allowed values.",equalValue:"The '{field}' field value must be equal to '{expected}'.",equalField:"The '{field}' field value must be equal to '{expected}' field value.",forbidden:"The '{field}' field is forbidden.",function:"The '{field}' field must be a function.",email:"The '{field}' field must be a valid e-mail.",luhn:"The '{field}' field must be a valid checksum luhn.",mac:"The '{field}' field must be a valid MAC address.",object:"The '{field}' must be an Object.",objectStrict:"The object '{field}' contains forbidden keys: '{actual}'.",url:"The '{field}' field must be a valid URL.",uuid:"The '{field}' field must be a valid UUID.",uuidVersion:"The '{field}' field must be a valid UUID version provided.",classInstanceOf:"The '{field}' field must be an instance of the '{expected}' class."},C=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,A=/^\S+@\S+\.\S+$/,T=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/,I=/["'\\\n\r\u2028\u2029]/g,V=/^-?[0-9]\d*(\.\d+)?$/,M=/^[a-zA-Z]+$/,F=/^[a-zA-Z0-9]+$/,q=/^[a-zA-Z0-9_-]+$/,R=/^[0-9a-fA-F]+$/,P=/^https?:\/\/\S+/,$=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$/i,L=/^((([a-f0-9][a-f0-9]+[-]){5}|([a-f0-9][a-f0-9]+[:]){5})([a-f0-9][a-f0-9])$)|(^([a-f0-9][a-f0-9][a-f0-9][a-f0-9]+[.]){2}([a-f0-9][a-f0-9][a-f0-9][a-f0-9]))$/i;return t.prototype.validate=function(t,e){return this.compile(e)(t)},t.prototype.wrapRequiredCheckSourceCode=function(t,e,n){var r=[],a=null!=t.schema.default?JSON.stringify(t.schema.default):null;return r.push("\n\t\t\tif (value === undefined || value === null) {\n\t\t"),!0===t.schema.optional||"forbidden"==t.schema.type?null!=a&&n?r.push(n+" = "+a+";"):r.push("// Do nothing, it's an optional field"):null!=a&&n?r.push(n+" = "+a+";"):r.push(this.makeError({type:"required",actual:"value",messages:t.messages})),r.push("} else {"),e&&r.push(e),r.push("\t\t}"),r.join("\n")},t.prototype.compile=function(t){if(null===t||"object"!=typeof t)throw Error("Invalid schema.");var n=this,r={index:0,rules:[],fn:[],customs:{}};if(this.cache.clear(),!0!==t.$$root)if(Array.isArray(t))t=this.getRuleFromSchema(t).schema;else{var a=Object.assign({},t);t={type:"object",strict:a.$$strict,properties:a},delete a.$$strict}a=["var errors = [];","var field;","var parent = null;"],t=this.getRuleFromSchema(t),a.push(this.compileRule(t,r,null,"context.fn[%%INDEX%%](value, field, null, errors, context);","value")),a.push("\n\t\t\t\t"+this.makeCustomValidator({path:"$$root",schema:t.schema,context:r,messages:t.messages})+"\n\t\t"),a.push("if (errors.length) {"),a.push('\n\t\t\treturn errors.map(err => {\n\t\t\t\tif (err.message)\n\t\t\t\t\terr.message = err.message\n\t\t\t\t\t\t.replace(/\\{field\\}/g, err.field || "")\n\t\t\t\t\t\t.replace(/\\{expected\\}/g, err.expected != null ? err.expected : "")\n\t\t\t\t\t\t.replace(/\\{actual\\}/g, err.actual != null ? err.actual : "");\n\n\t\t\t\treturn err;\n\t\t\t});\n\t\t'),a.push("}"),a.push("return true;"),t=a.join("\n");var s=new Function("value","context",t);if(this.opts.debug){var i=function(t){return t};"undefined"==typeof window&&(i=e),r.fn.forEach(function(t,e){return console.log(i("// Context.fn["+e+"]\n"+t.toString()))}),console.log(i("// Main check function\n"+s.toString()))}return this.cache.clear(),function(t){return r.data=t,s.call(n,t,r)}},t.prototype.compileRule=function(t,e,n,r,a){var s=[],i=this.cache.get(t.schema);return i?(t=i,t.cycle=!0,t.cycleStack=[],s.push(this.wrapRequiredCheckSourceCode(t,"\n\t\t\t\tvar rule = context.rules["+t.index+"];\n\t\t\t\tif (rule.cycleStack.indexOf(value) === -1) {\n\t\t\t\t\trule.cycleStack.push(value);\n\t\t\t\t\t"+r.replace("%%INDEX%%",t.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",a))):(this.cache.set(t.schema,t),t.index=e.index,e.rules[e.index]=t,i=null!=n?n:"$$root",e.customs[i]?e.customs[i].schema=t.schema:e.customs[i]={schema:t.schema},e.index++,n=t.ruleFunction.call(this,t,n,e),n.source?(n=new Function("value","field","parent","errors","context",n.source),e.fn[t.index]=n,s.push(this.wrapRequiredCheckSourceCode(t,r.replace("%%INDEX%%",t.index),a))):s.push(this.wrapRequiredCheckSourceCode(t))),s.join("\n")},t.prototype.getRuleFromSchema=function(t){var e=this;if("string"==typeof t){var n=t.split("|").map(function(t){return t.trim()});t={type:n[0]},n.slice(1).map(function(e){var n=e.indexOf(":");if(-1!==n){var r=e.substr(0,n).trim();"true"===(e=e.substr(n+1).trim())||"false"===e?e="true"===e:Number.isNaN(Number(e))||(e=Number(e)),t[r]=e}else e.startsWith("no-")?t[e.slice(3)]=!1:t[e]=!0})}else if(Array.isArray(t)){if(0==t.length)throw Error("Invalid schema.");(t={type:"multi",rules:t}).rules.map(function(t){return e.getRuleFromSchema(t)}).every(function(t){return 1==t.schema.optional})&&(t.optional=!0)}if((n=this.aliases[t.type])&&(delete t.type,t=E(t,n,{skipIfExist:!0})),!(n=this.rules[t.type]))throw Error("Invalid '"+t.type+"' type in validator schema.");return{messages:Object.assign({},this.messages,t.messages),schema:E(t,this.defaults[t.type],{skipIfExist:!0}),ruleFunction:n}},t.prototype.makeError=function(t){var e=t.type,n=t.field,r=t.expected,a=t.actual,s={type:'"'+e+'"',message:'"'+t.messages[e]+'"'};return s.field=n?'"'+n+'"':"field",r&&(s.expected=r),a&&(s.actual=a),"errors.push({ "+Object.keys(s).map(function(t){return t+": "+s[t]}).join(", ")+" });"},t.prototype.makeCustomValidator=function(t){var e=t.vName;void 0===e&&(e="value");var n=t.fnName;void 0===n&&(n="custom");var r=t.path,a=t.context,s=t.messages;return"function"==typeof t.schema[n]?(t=null!=r?r:"$$root",a.customs[t]?a.customs[t].messages=s:a.customs[t]={messages:s},this.opts.useNewCustomCheckerFunction?'\n\t\t\t\t\tconst rule = context.customs["'+t+'"];\n\t\t\t\t\tconst fnCustomErrors = [];\n\t\t\t\t\t'+e+" = rule.schema."+n+".call(this, "+e+', fnCustomErrors, rule.schema, "'+r+'", parent, context);\n\t\t\t\t\tif (Array.isArray(fnCustomErrors)) {\n\t\t\t\t\tfnCustomErrors.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t':'\n\t\t\t\tconst rule = context.customs["'+t+'"];\n\t\t\t\tconst res = rule.schema.'+n+".call(this, "+e+', rule.schema, "'+r+'", parent, context);\n\t\t\t\tif (Array.isArray(res)) {\n\t\t\t\t\tres.forEach(err => errors.push(Object.assign({ message: rule.messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t'):""},t.prototype.add=function(t,e){this.rules[t]=e},t.prototype.alias=function(t,e){if(this.rules[t])throw Error("Alias name must not be a rule name");this.aliases[t]=e},t}var f=f||{};f.scope={},f.arrayIteratorImpl=function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}},f.arrayIterator=function(t){return{next:f.arrayIteratorImpl(t)}},f.ASSUME_ES5=!1,f.ASSUME_NO_NATIVE_MAP=!1,f.ASSUME_NO_NATIVE_SET=!1,f.SIMPLE_FROUND_POLYFILL=!1,f.defineProperty=f.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){t!=Array.prototype&&t!=Object.prototype&&(t[e]=n.value)},f.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,t];for(var e=0;e<t.length;++e){var n=t[e];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")},f.global=f.getGlobal(this),f.SYMBOL_PREFIX="jscomp_symbol_",f.initSymbol=function(){f.initSymbol=function(){},f.global.Symbol||(f.global.Symbol=f.Symbol)},f.SymbolClass=function(t,e){this.$jscomp$symbol$id_=t,f.defineProperty(this,"description",{configurable:!0,writable:!0,value:e})},f.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_},f.Symbol=function(){function t(n){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new f.SymbolClass(f.SYMBOL_PREFIX+(n||"")+"_"+e++,n)}var e=0;return t}(),f.initSymbolIterator=function(){f.initSymbol();var t=f.global.Symbol.iterator;t||(t=f.global.Symbol.iterator=f.global.Symbol("Symbol.iterator")),"function"!=typeof Array.prototype[t]&&f.defineProperty(Array.prototype,t,{configurable:!0,writable:!0,value:function(){return f.iteratorPrototype(f.arrayIteratorImpl(this))}}),f.initSymbolIterator=function(){}},f.initSymbolAsyncIterator=function(){f.initSymbol();var t=f.global.Symbol.asyncIterator;t||(t=f.global.Symbol.asyncIterator=f.global.Symbol("Symbol.asyncIterator")),f.initSymbolAsyncIterator=function(){}},f.iteratorPrototype=function(t){return f.initSymbolIterator(),t={next:t},t[f.global.Symbol.iterator]=function(){return this},t},f.iteratorFromArray=function(t,e){f.initSymbolIterator(),t instanceof String&&(t+="");var n=0,r={next:function(){if(n<t.length){var a=n++;return{value:e(a,t[a]),done:!1}}return r.next=function(){return{done:!0,value:void 0}},r.next()}};return r[Symbol.iterator]=function(){return r},r},f.polyfill=function(t,e){if(e){var n=f.global;t=t.split(".");for(var r=0;r<t.length-1;r++){var a=t[r];a in n||(n[a]={}),n=n[a]}(e=e(r=n[t=t[t.length-1]]))!=r&&null!=e&&f.defineProperty(n,t,{configurable:!0,writable:!0,value:e})}},f.polyfill("Array.prototype.keys",function(t){return t||function(){return f.iteratorFromArray(this,function(t){return t})}},"es6","es3"),f.polyfill("Array.prototype.values",function(t){return t||function(){return f.iteratorFromArray(this,function(t,e){return e})}},"es8","es3"),f.checkEs6ConformanceViaProxy=function(){try{var t={},e=Object.create(new f.global.Proxy(t,{get:function(n,r,a){return n==t&&"q"==r&&a==e}}));return!0===e.q}catch(t){return!1}},f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,f.ES6_CONFORMANCE=f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&f.checkEs6ConformanceViaProxy(),f.makeIterator=function(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):f.arrayIterator(t)},f.owns=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},f.polyfill("WeakMap",function(t){function e(t){if(this.id_=(u+=Math.random()+1).toString(),t){t=f.makeIterator(t);for(var e;!(e=t.next()).done;)e=e.value,this.set(e[0],e[1])}}function n(){}function r(t){var e=typeof t;return"object"===e&&null!==t||"function"===e}function a(t){if(!f.owns(t,i)){var e=new n;f.defineProperty(t,i,{value:e})}}function s(t){var e=Object[t];e&&(Object[t]=function(t){return t instanceof n?t:(a(t),e(t))})}if(f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&f.ES6_CONFORMANCE)return t}else if(function(){if(!t||!Object.seal)return!1;try{var e=Object.seal({}),n=Object.seal({}),r=new t([[e,2],[n,3]]);return 2==r.get(e)&&3==r.get(n)&&(r.delete(e),r.set(n,4),!r.has(e)&&4==r.get(n))}catch(t){return!1}}())return t;var i="$jscomp_hidden_"+Math.random();s("freeze"),s("preventExtensions"),s("seal");var u=0;return e.prototype.set=function(t,e){if(!r(t))throw Error("Invalid WeakMap key");if(a(t),!f.owns(t,i))throw Error("WeakMap key fail: "+t);return t[i][this.id_]=e,this},e.prototype.get=function(t){return r(t)&&f.owns(t,i)?t[i][this.id_]:void 0},e.prototype.has=function(t){return r(t)&&f.owns(t,i)&&f.owns(t[i],this.id_)},e.prototype.delete=function(t){return!!(r(t)&&f.owns(t,i)&&f.owns(t[i],this.id_))&&delete t[i][this.id_]},e},"es6","es3"),f.MapEntry=function(){},f.polyfill("Map",function(t){function e(){var t={};return t.previous=t.next=t.head=t}function n(t,e){var n=t.head_;return f.iteratorPrototype(function(){if(n){for(;n.head!=t.head_;)n=n.previous;for(;n.next!=n.head;)return n=n.next,{done:!1,value:e(n)};n=null}return{done:!0,value:void 0}})}function r(t,e){var n=e&&typeof e;"object"==n||"function"==n?s.has(e)?n=s.get(e):(n=""+ ++i,s.set(e,n)):n="p_"+e;var r=t.data_[n];if(r&&f.owns(t.data_,n))for(t=0;t<r.length;t++){var a=r[t];if(e!==e&&a.key!==a.key||e===a.key)return{id:n,list:r,index:t,entry:a}}return{id:n,list:r,index:-1,entry:void 0}}function a(t){if(this.data_={},this.head_=e(),this.size=0,t){t=f.makeIterator(t);for(var n;!(n=t.next()).done;)n=n.value,this.set(n[0],n[1])}}if(f.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&f.ES6_CONFORMANCE)return t}else if(function(){if(f.ASSUME_NO_NATIVE_MAP||!t||"function"!=typeof t||!t.prototype.entries||"function"!=typeof Object.seal)return!1;try{var e=Object.seal({x:4}),n=new t(f.makeIterator([[e,"s"]]));if("s"!=n.get(e)||1!=n.size||n.get({x:4})||n.set({x:4},"t")!=n||2!=n.size)return!1;var r=n.entries(),a=r.next();return!a.done&&a.value[0]==e&&"s"==a.value[1]&&!((a=r.next()).done||4!=a.value[0].x||"t"!=a.value[1]||!r.next().done)}catch(t){return!1}}())return t;f.initSymbolIterator();var s=new WeakMap;a.prototype.set=function(t,e){var n=r(this,t=0===t?0:t);return n.list||(n.list=this.data_[n.id]=[]),n.entry?n.entry.value=e:(n.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:t,value:e},n.list.push(n.entry),this.head_.previous.next=n.entry,this.head_.previous=n.entry,this.size++),this},a.prototype.delete=function(t){return!(!(t=r(this,t)).entry||!t.list)&&(t.list.splice(t.index,1),t.list.length||delete this.data_[t.id],t.entry.previous.next=t.entry.next,t.entry.next.previous=t.entry.previous,t.entry.head=null,this.size--,!0)},a.prototype.clear=function(){this.data_={},this.head_=this.head_.previous=e(),this.size=0},a.prototype.has=function(t){return!!r(this,t).entry},a.prototype.get=function(t){return(t=r(this,t).entry)&&t.value},a.prototype.entries=function(){return n(this,function(t){return[t.key,t.value]})},a.prototype.keys=function(){return n(this,function(t){return t.key})},a.prototype.values=function(){return n(this,function(t){return t.value})},a.prototype.forEach=function(t,e){for(var n,r=this.entries();!(n=r.next()).done;)n=n.value,t.call(e,n[1],n[0],this)},a.prototype[Symbol.iterator]=a.prototype.entries;var i=0;return a},"es6","es3"),f.assign="function"==typeof Object.assign?Object.assign:function(t,e){for(var n=1;n<arguments.length;n++){var r=arguments[n];if(r)for(var a in r)f.owns(r,a)&&(t[a]=r[a])}return t},f.polyfill("Object.assign",function(t){return t||f.assign},"es6","es3"),f.polyfill("Number.isNaN",function(t){return t||function(t){return"number"==typeof t&&isNaN(t)}},"es6","es3"),f.checkStringArgs=function(t,e,n){if(null==t)throw new TypeError("The 'this' value for String.prototype."+n+" must not be null or undefined");if(e instanceof RegExp)throw new TypeError("First argument to String.prototype."+n+" must not be a regular expression");return t+""},f.polyfill("String.prototype.startsWith",function(t){return t||function(t,e){var n=f.checkStringArgs(this,t,"startsWith");t+="";var r=n.length,a=t.length;e=Math.max(0,Math.min(0|e,n.length));for(var s=0;s<a&&e<r;)if(n[e++]!=t[s++])return!1;return s>=a}},"es6","es3");var v=this;"object"==typeof exports&&"undefined"!=typeof module?module.exports=w():"function"==typeof define&&define.amd?define(w):(v=v||self,v.FastestValidator=w());

@@ -84,18 +84,9 @@ "use strict";

const itemPath = path + "[]";
const rule = this.getRuleFromSchema(schema.items);
const innerSource = `
arr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context);
${this.makeCustomValidator({ vName: "arr[i]", path, schema: rule.schema, context, messages })}
${this.makeCustomValidator({ vName: "arr[i]", path: itemPath, schema: rule.schema, context, messages })}
`;
src.push(this.compileRule(rule, context, path, innerSource, "arr[i]"));
/*
const res = rule.ruleFunction.call(this, rule, path, context);
context.rules[context.index] = rule;
if (res.source) {
const fn = new Function("value", "field", "parent", "errors", "context", res.source);
context.fn[context.index] = fn;
src.push(`arr[i] = context.fn[${context.index}](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context);`);
}
context.index++;
*/
src.push(this.compileRule(rule, context, itemPath, innerSource, "arr[i]"));
src.push(`

@@ -102,0 +93,0 @@ }

@@ -153,2 +153,3 @@ "use strict";

"var field;",
"var parent = null;",
];

@@ -158,2 +159,5 @@

sourceCode.push(this.compileRule(rule, context, null, "context.fn[%%INDEX%%](value, field, null, errors, context);", "value"));
sourceCode.push(`
${this.makeCustomValidator({ path: "$$root", schema: rule.schema, context, messages: rule.messages })}
`);

@@ -230,4 +234,5 @@ sourceCode.push("if (errors.length) {");

if (context.customs[path]) context.customs[path].schema = rule.schema;
else context.customs[path] = { schema: rule.schema };
const customPath = path != null ? path : "$$root";
if (context.customs[customPath]) context.customs[customPath].schema = rule.schema;
else context.customs[customPath] = { schema: rule.schema };

@@ -353,8 +358,9 @@ context.index++;

if (typeof schema[fnName] == "function") {
if (context.customs[path]) context.customs[path].messages = messages;
else context.customs[path] = { messages };
const customPath = path != null ? path : "$$root";
if (context.customs[customPath]) context.customs[customPath].messages = messages;
else context.customs[customPath] = { messages };
if (this.opts.useNewCustomCheckerFunction) {
return `
const rule = context.customs["${path}"];
const rule = context.customs["${customPath}"];
const fnCustomErrors = [];

@@ -369,3 +375,3 @@ ${vName} = rule.schema.${fnName}.call(this, ${vName}, fnCustomErrors, rule.schema, "${path}", parent, context);

return `
const rule = context.customs["${path}"];
const rule = context.customs["${customPath}"];
const res = rule.schema.${fnName}.call(this, ${vName}, rule.schema, "${path}", parent, context);

@@ -372,0 +378,0 @@ if (Array.isArray(res)) {

{
"name": "fastest-validator",
"version": "1.4.0",
"version": "1.4.1",
"description": "The fastest JS validator library for NodeJS",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc