fastest-validator
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -0,1 +1,9 @@ | ||
<a name="1.10.1"></a> | ||
# 1.10.1 (2021-03-22) | ||
## Changes | ||
- fix issue with regex `pattern` in `string` rule [#221](https://github.com/icebob/fastest-validator/pull/221) | ||
- fix returned value issue in `email` rule in case of `empty: false` [#224](https://github.com/icebob/fastest-validator/pull/224) | ||
-------------------------------------------------- | ||
<a name="1.10.0"></a> | ||
@@ -2,0 +10,0 @@ # 1.10.0 (2021-02-03) |
@@ -249,15 +249,17 @@ (function (global, factory) { | ||
var currencySymbol = schema.currencySymbol || null; | ||
var thousandSeparator = schema.thousandSeparator || ','; | ||
var decimalSeparator = schema.decimalSeparator || '.'; | ||
var thousandSeparator = schema.thousandSeparator || ","; | ||
var decimalSeparator = schema.decimalSeparator || "."; | ||
var customRegex = schema.customRegex; | ||
var isCurrencySymbolMandatory = !schema.symbolOptional; | ||
var finalRegex = CURRENCY_REGEX.replace(/~1/g, currencySymbol ? (("\\" + currencySymbol + ((isCurrencySymbolMandatory ? '' : '?')))) : '') | ||
.replace('~2', thousandSeparator) | ||
.replace('~3', decimalSeparator); | ||
var finalRegex = CURRENCY_REGEX.replace(/~1/g, currencySymbol ? (("\\" + currencySymbol + ((isCurrencySymbolMandatory ? "" : "?")))) : "") | ||
.replace("~2", thousandSeparator) | ||
.replace("~3", decimalSeparator); | ||
var src = []; | ||
src.push(("\n\t\tif (!value.match(" + (customRegex || new RegExp(finalRegex)) + ")) {\n\t\t\t" + (this.makeError({ type: "currency", actual: "value", messages: messages })) + "\n\t\t\treturn value;\n\t\t}\n\n\t\treturn value;\n\t")); | ||
return { | ||
source: ("\n\t\t\tif (!value.match(" + (customRegex || new RegExp(finalRegex)) + ")){\n\t\t\treturn " + (this.makeError({ | ||
type: "currency", | ||
actual: "value", | ||
messages: messages | ||
})) + "\n\t\t\t}\n\t\t\treturn value;\n\t\t") | ||
source: src.join("\n") | ||
}; | ||
@@ -307,3 +309,3 @@ }; | ||
if (!schema.empty) { | ||
src.push(("\n\t\t\tif (value.length === 0) {\n\t\t\t\treturn " + (this.makeError({ type: "emailEmpty", actual: "value", messages: messages })) + "\n\t\t\t}\n\t\t")); | ||
src.push(("\n\t\t\tif (value.length === 0) {\n\t\t\t\t" + (this.makeError({ type: "emailEmpty", actual: "value", messages: messages })) + "\n\t\t\t\treturn value;\n\t\t\t}\n\t\t")); | ||
} else { | ||
@@ -720,3 +722,3 @@ src.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"); | ||
var patternValidator = "\n\t\t\tif (!" + (pattern.toString()) + ".test(value))\n\t\t\t\t" + (this.makeError({ type: "stringPattern", expected: "\"" + pattern.toString().replace("\"", "\\\"") + "\"", actual: "origValue", messages: messages })) + "\n\t\t"; | ||
var patternValidator = "\n\t\t\tif (!" + (pattern.toString()) + ".test(value))\n\t\t\t\t" + (this.makeError({ type: "stringPattern", expected: ("\"" + (pattern.toString().replace(/"/g, "\\$&")) + "\""), actual: "origValue", messages: messages })) + "\n\t\t"; | ||
@@ -832,3 +834,3 @@ src.push(("\n\t\t\tif (" + (schema.empty) + " === true && len === 0) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\t" + patternValidator + "\n\t\t\t}\n\t\t")); | ||
if (!schema.empty) { | ||
src.push(("\n\t\t\tif (value.length === 0) {\n\t\t\t\treturn " + (this.makeError({ type: "urlEmpty", actual: "value", messages: messages })) + "\n\t\t\t}\n\t\t")); | ||
src.push(("\n\t\t\tif (value.length === 0) {\n\t\t\t\t" + (this.makeError({ type: "urlEmpty", actual: "value", messages: messages })) + "\n\t\t\t\treturn value;\n\t\t\t}\n\t\t")); | ||
} else { | ||
@@ -835,0 +837,0 @@ src.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"); |
@@ -1,1 +0,1 @@ | ||
"use strict";function v(){function t(t){if(this.opts={},this.defaults={},this.messages=Object.assign({},N),this.rules={any:k,array:S,boolean:E,class:x,custom:b,currency:y,date:g,email:v,enum:d,equal:m,forbidden:h,function:p,multi:c,number:f,object:o,objectID:l,string:u,tuple:i,url:s,uuid:a,mac:r,luhn:n},this.aliases={},this.cache=new Map,t){if(O(this.opts,t),t.defaults&&O(this.defaults,t.defaults),t.messages)for(var e in t.messages)this.addMessage(e,t.messages[e]);if(t.aliases)for(var j in t.aliases)this.alias(j,t.aliases[j]);if(t.customRules)for(var T in t.customRules)this.add(T,t.customRules[T]);if(t.plugins){if(t=t.plugins,!Array.isArray(t))throw Error("Plugins type must be array");t.forEach(this.plugin.bind(this))}}}function e(t){return _||(_=T(),A={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},w=T(),I={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=_.format(t,A),w.highlight(t,I)}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 (!"+Y.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 (!"+z.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"),7>parseInt(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 0:\n\t\tcase 1:\n\t\tcase 2:\n\t\tcase 6:\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(val.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){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\t"),e.empty?n.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):n.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\treturn "+this.makeError({type:"urlEmpty",actual:"value",messages:t})+"\n\t\t\t}\n\t\t"),n.push("\n\t\tif (!"+D.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:n.join("\n")}}function i(t,e,n){var r=t.schema,a=t.messages;if(t=[],null!=r.items){if(!Array.isArray(r.items))throw Error("Invalid '"+r.type+"' schema. The 'items' field must be an array.");if(0===r.items.length)throw Error("Invalid '"+r.type+"' schema. The 'items' field must not be an empty array.")}if(t.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"tuple",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:"tupleEmpty",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),null!=r.items)for(t.push("\n\t\t\tif ("+r.empty+" !== false && len === 0) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (len !== "+r.items.length+") {\n\t\t\t\t"+this.makeError({type:"tupleLength",expected:r.items.length,actual:"len",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),t.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t"),a=0;a<r.items.length;a++){var s=e+"["+a+"]",i=this.getRuleFromSchema(r.items[a]);t.push(this.compileRule(i,n,s,"\n\t\t\tarr["+a+"] = context.fn[%%INDEX%%](arr["+a+'], (parentField ? parentField : "") + "[" + '+a+' + "]", parent, errors, context);\n\t\t',"arr["+a+"]"))}return t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function u(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)),a="\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",n.push("\n\t\t\tif ("+e.empty+" === true && len === 0) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\t"+a+"\n\t\t\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 (!"+L.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(!"+V.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(!"+R.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 || !"+$.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringHex",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.singleLine&&n.push('\n\t\t\tif(value.includes("\\n")) {\n\t\t\t\t'+this.makeError({type:"stringSingleLine",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.base64&&n.push("\n\t\t\tif(!"+U.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringBase64",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 l(t,e,n){e=t.schema;var r=t.messages;t=t.index;var a=[];return n.customs[t]?n.customs[t].schema=e:n.customs[t]={schema:e},a.push("\n\t\tconst ObjectID = context.customs["+t+"].schema.ObjectID;\n\t\tif (!ObjectID.isValid(value)) {\n\t\t\t"+this.makeError({type:"objectID",actual:"value",messages:r})+"\n\t\t\treturn;\n\t\t}\n\t"),!0===e.convert?a.push("return new ObjectID(value)"):"hexString"===e.convert?a.push("return value.toString()"):a.push("return value"),{source:a.join("\n")}}function o(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=j(l),f=P.test(o)?"."+o:"['"+o+"']",c="parentObj"+f,p=(e?e+".":"")+l;a.push("\n// Field: "+j(p)),a.push('field = parentField ? parentField + "'+f+'" : "'+o+'";'),a.push("value = "+c+";"),l=this.getRuleFromSchema(s[l]),a.push(this.compileRule(l,n,p,"\n\t\t\t\t"+c+" = context.fn[%%INDEX%%](value, field, parentObj, errors, context);\n\t\t\t",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"))}return null==r.minProps&&null==r.maxProps||(r.strict?a.push("\n\t\t\t\tprops = Object.keys("+(s?"parentObj":"value")+");\n\t\t\t"):a.push("\n\t\t\t\tvar props = Object.keys("+(s?"parentObj":"value")+");\n\t\t\t\t"+(s?"field = parentField;":"")+"\n\t\t\t")),null!=r.minProps&&a.push("\n\t\t\tif (props.length < "+r.minProps+") {\n\t\t\t\t"+this.makeError({type:"objectMinProps",expected:r.minProps,actual:"props.length",messages:t})+"\n\t\t\t}\n\t\t"),null!=r.maxProps&&a.push("\n\t\t\tif (props.length > "+r.maxProps+") {\n\t\t\t\t"+this.makeError({type:"objectMaxProps",expected:r.maxProps,actual:"props.length",messages:t})+"\n\t\t\t}\n\t\t"),s?a.push("\n\t\t\treturn parentObj;\n\t\t"):a.push("\n\t\t\treturn value;\n\t\t"),{source:a.join("\n")}}function f(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 c(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 p(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 h(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 m(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 d(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 v(t){var e=t.schema;t=t.messages;var n=[],r="precise"==e.mode?F:M,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.empty?n.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):n.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\treturn "+this.makeError({type:"emailEmpty",actual:"value",messages:t})+"\n\t\t\t}\n\t\t"),e.normalize&&(a=!0,n.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t")),null!=e.min&&n.push("\n\t\t\tif (value.length < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"emailMin",expected:e.min,actual:"value.length",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (value.length > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"emailMax",expected:e.max,actual:"value.length",messages:t})+"\n\t\t\t}\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 g(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 y(t){var e=t.schema;t=t.messages;var n=e.currencySymbol||null,r=e.thousandSeparator||",",a=e.decimalSeparator||".",s=e.customRegex;return e=!e.symbolOptional,e="(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$".replace(/~1/g,n?"\\"+n+(e?"":"?"):"").replace("~2",r).replace("~3",a),{source:"\n\t\t\tif (!value.match("+(s||new RegExp(e))+")){\n\t\t\treturn "+this.makeError({type:"currency",actual:"value",messages:t})+"\n\t\t\t}\n\t\t\treturn value;\n\t\t"}}function b(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,ruleIndex:t.index})+"\n\t\treturn value;\n\t"),{source:r.join("\n")}}function x(t,e,n){e=t.schema;var r=t.messages;t=t.index;var a=[],s=e.instanceOf.name?e.instanceOf.name:"<UnknowClass>";return n.customs[t]?n.customs[t].schema=e:n.customs[t]={schema:e},a.push("\n\t\tif (!(value instanceof context.customs["+t+"].schema.instanceOf))\n\t\t\t"+this.makeError({type:"classInstanceOf",actual:"value",expected:"'"+s+"'",messages:r})+"\n\t"),a.push("\n\t\treturn value;\n\t"),{source:a.join("\n")}}function E(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 S(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),t.push(this.compileRule(r,n,e,'arr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context)',"arr[i]")),t.push("\n\t\t\t}\n\t\t")),t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function k(){var t=[];return t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function O(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]||{},O(t[r],e[r],n)):!0===n.skipIfExist&&void 0!==t[r]||(t[r]=e[r])}return t}function j(t){return t.replace(C,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 T(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}var _,A,w,I,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.",stringSingleLine:"The '{field}' field must be a single line string.",stringBase64:"The '{field}' field must be a base64 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.",tuple:"The '{field}' field must be an array.",tupleEmpty:"The '{field}' field must not be an empty array.",tupleLength:"The '{field}' field must contain {expected} items.",boolean:"The '{field}' field must be a boolean.",currency:"The '{field}' must be a valid currency format",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.",emailEmpty:"The '{field}' field must not be empty.",emailMin:"The '{field}' field length must be greater than or equal to {expected} characters long.",emailMax:"The '{field}' field length must be less than or equal to {expected} characters long.",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}'.",objectMinProps:"The object '{field}' must contain at least {expected} properties.",objectMaxProps:"The object '{field}' must contain {expected} properties at most.",url:"The '{field}' field must be a valid URL.",urlEmpty:"The '{field}' field must not be empty.",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.",objectID:"The '{field}' field must be an valid ObjectID"},F=/^(([^<>()[\]\\.,;:\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,}))$/,M=/^\S+@\S+\.\S+$/,P=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/,C=/["'\\\n\r\u2028\u2029]/g,L=/^-?[0-9]\d*(\.\d+)?$/,V=/^[a-zA-Z]+$/,R=/^[a-zA-Z0-9]+$/,q=/^[a-zA-Z0-9_-]+$/,$=/^[0-9a-fA-F]+$/,U=/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+/]{3}=)?$/,D=/^https?:\/\/\S+/,z=/^([0-9a-f]{8}-[0-9a-f]{4}-[1-6][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}|[0]{8}-[0]{4}-[0]{4}-[0]{4}-[0]{12})$/i,Y=/^((([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,r){var a=[],s=!0===t.schema.optional||"forbidden"===t.schema.type,i=!0===t.schema.optional||!0===t.schema.nullable||"forbidden"===t.schema.type;return null!=t.schema.default?(s=!1,!0!==t.schema.nullable&&(i=!1),"function"==typeof t.schema.default?(n.customs[t.index]||(n.customs[t.index]={}),n.customs[t.index].defaultFn=t.schema.default,t="context.customs["+t.index+"].defaultFn()"):t=JSON.stringify(t.schema.default),r="\n\t\t\t\tvalue = "+t+";\n\t\t\t\t"+r+" = value;\n\t\t\t"):r=this.makeError({type:"required",actual:"value",messages:t.messages}),a.push("\n\t\t\tif (value === undefined) { "+(s?"\n// allow undefined\n":r)+" }\n\t\t\telse if (value === null) { "+(i?"\n// allow null\n":r)+" }\n\t\t\t"+(e?"else { "+e+" }":"")+"\n\t\t"),a.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("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%%/g,t.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",e,a))):(this.cache.set(t.schema,t),t.index=e.index,e.rules[e.index]=t,i=null!=n?n:"$$root",e.index++,n=t.ruleFunction.call(this,t,n,e),n.source=n.source.replace(/%%INDEX%%/g,t.index),n=new Function("value","field","parent","errors","context",n.source),e.fn[t.index]=n,s.push(this.wrapRequiredCheckSourceCode(t,r.replace(/%%INDEX%%/g,t.index),e,a)),s.push(this.makeCustomValidator({vName:a,path:i,schema:t.schema,context:e,messages:t.messages,ruleIndex:t.index}))),s.join("\n")},t.prototype.getRuleFromSchema=function(t){var e=this;if("string"==typeof t)t=this.parseShortHand(t);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(t.$$type){var n=this.getRuleFromSchema(t.$$type).schema;delete t.$$type;var r,a=Object.assign({},t);for(r in t)delete t[r];O(t,n,{skipIfExist:!0}),t.props=a}if((n=this.aliases[t.type])&&(delete t.type,t=O(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:O(t,this.defaults[t.type],{skipIfExist:!0}),ruleFunction:n}},t.prototype.parseShortHand=function(t){var e=(t=t.split("|").map(function(t){return t.trim()}))[0],n=e.endsWith("[]")?this.getRuleFromSchema({type:"array",items:e.slice(0,-2)}).schema:{type:t[0]};return t.slice(1).map(function(t){var e=t.indexOf(":");if(-1!==e){var r=t.substr(0,e).trim();"true"===(t=t.substr(e+1).trim())||"false"===t?t="true"===t:Number.isNaN(Number(t))||(t=Number(t)),n[r]=t}else t.startsWith("no-")?n[t.slice(3)]=!1:n[t]=!0}),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",null!=r&&(s.expected=r),null!=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.ruleIndex,a=t.path,s=t.schema,i=t.context,u=t.messages;t="rule"+r;var l="fnCustomErrors"+r;return"function"==typeof s[n]?(i.customs[r]?(i.customs[r].messages=u,i.customs[r].schema=s):i.customs[r]={messages:u,schema:s},this.opts.useNewCustomCheckerFunction?"\n const "+t+" = context.customs["+r+"];\n\t\t\t\t\tconst "+l+" = [];\n\t\t\t\t\t"+e+" = "+t+".schema."+n+".call(this, "+e+", "+l+" , "+t+'.schema, "'+a+'", parent, context);\n\t\t\t\t\tif (Array.isArray('+l+" )) {\n "+l+" .forEach(err => errors.push(Object.assign({ message: "+t+".messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t":(s="res_"+t,"\n\t\t\t\tconst "+t+" = context.customs["+r+"];\n\t\t\t\tconst "+s+" = "+t+".schema."+n+".call(this, "+e+", "+t+'.schema, "'+a+'", parent, context);\n\t\t\t\tif (Array.isArray('+s+")) {\n\t\t\t\t\t"+s+".forEach(err => errors.push(Object.assign({ message: "+t+".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.addMessage=function(t,e){this.messages[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.prototype.plugin=function(t){if("function"!=typeof t)throw Error("Plugin fn type must be function");return t(this)},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.ISOLATE_POLYFILLS=!1,f.defineProperty=f.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){return t==Array.prototype||t==Object.prototype?t:(t[e]=n.value,t)},f.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];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.IS_SYMBOL_NATIVE="function"==typeof Symbol&&"symbol"==typeof Symbol("x"),f.TRUST_ES6_POLYFILLS=!f.ISOLATE_POLYFILLS||f.IS_SYMBOL_NATIVE,f.polyfills={},f.propertyToPolyfillSymbol={},f.POLYFILL_PREFIX="$jscp$",f.polyfill=function(t,e,n,r){e&&(f.ISOLATE_POLYFILLS?f.polyfillIsolated(t,e,n,r):f.polyfillUnisolated(t,e,n,r))},f.polyfillUnisolated=function(t,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.polyfillIsolated=function(t,e,n){var r=t.split(".");t=1===r.length;var a=r[0];a=!t&&a in f.polyfills?f.polyfills:f.global;for(var s=0;s<r.length-1;s++){var i=r[s];i in a||(a[i]={}),a=a[i]}r=r[r.length-1],null!=(e=e(n=f.IS_SYMBOL_NATIVE&&"es6"===n?a[r]:null))&&(t?f.defineProperty(f.polyfills,r,{configurable:!0,writable:!0,value:e}):e!==n&&(f.propertyToPolyfillSymbol[r]=f.IS_SYMBOL_NATIVE?f.global.Symbol(r):f.POLYFILL_PREFIX+r,r=f.propertyToPolyfillSymbol[r],f.defineProperty(a,r,{configurable:!0,writable:!0,value:e})))},f.initSymbol=function(){},f.polyfill("Symbol",function(t){function e(t){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new n("jscomp_symbol_"+(t||"")+"_"+r++,t)}function n(t,e){this.$jscomp$symbol$id_=t,f.defineProperty(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;n.prototype.toString=function(){return this.$jscomp$symbol$id_};var r=0;return e},"es6","es3"),f.initSymbolIterator=function(){},f.polyfill("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var e="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),n=0;n<e.length;n++){var r=f.global[e[n]];"function"==typeof r&&"function"!=typeof r.prototype[t]&&f.defineProperty(r.prototype,t,{configurable:!0,writable:!0,value:function(){return f.iteratorPrototype(f.arrayIteratorImpl(this))}})}return t},"es6","es3"),f.initSymbolAsyncIterator=function(){},f.iteratorPrototype=function(t){return t={next:t},t[Symbol.iterator]=function(){return this},t},f.iteratorFromArray=function(t,e){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("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.owns=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},f.assign=f.TRUST_ES6_POLYFILLS&&"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.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.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;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.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.endsWith",function(t){return t||function(t,e){var n=f.checkStringArgs(this,t,"endsWith");t+="",void 0===e&&(e=n.length),e=Math.max(0,Math.min(0|e,n.length));for(var r=t.length;0<r&&0<e;)if(n[--e]!=t[--r])return!1;return 0>=r}},"es6","es3"),f.polyfill("Number.isNaN",function(t){return t||function(t){return"number"==typeof t&&isNaN(t)}},"es6","es3"),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 u=this;"object"==typeof exports&&"undefined"!=typeof module?module.exports=v():"function"==typeof define&&define.amd?define(v):(u=u||self,u.FastestValidator=v()); | ||
"use strict";function v(){function t(t){if(this.opts={},this.defaults={},this.messages=Object.assign({},N),this.rules={any:k,array:S,boolean:E,class:x,custom:b,currency:y,date:v,email:d,enum:g,equal:m,forbidden:h,function:f,multi:p,number:c,object:o,objectID:l,string:u,tuple:i,url:s,uuid:a,mac:r,luhn:n},this.aliases={},this.cache=new Map,t){if(O(this.opts,t),t.defaults&&O(this.defaults,t.defaults),t.messages)for(var e in t.messages)this.addMessage(e,t.messages[e]);if(t.aliases)for(var j in t.aliases)this.alias(j,t.aliases[j]);if(t.customRules)for(var T in t.customRules)this.add(T,t.customRules[T]);if(t.plugins){if(t=t.plugins,!Array.isArray(t))throw Error("Plugins type must be array");t.forEach(this.plugin.bind(this))}}}function e(t){return _||(_=T(),A={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},w=T(),I={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=_.format(t,A),w.highlight(t,I)}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 (!"+Y.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 (!"+z.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"),7>parseInt(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 0:\n\t\tcase 1:\n\t\tcase 2:\n\t\tcase 6:\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(val.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){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\t"),e.empty?n.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):n.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\t"+this.makeError({type:"urlEmpty",actual:"value",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),n.push("\n\t\tif (!"+D.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:n.join("\n")}}function i(t,e,n){var r=t.schema,a=t.messages;if(t=[],null!=r.items){if(!Array.isArray(r.items))throw Error("Invalid '"+r.type+"' schema. The 'items' field must be an array.");if(0===r.items.length)throw Error("Invalid '"+r.type+"' schema. The 'items' field must not be an empty array.")}if(t.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"tuple",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:"tupleEmpty",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),null!=r.items)for(t.push("\n\t\t\tif ("+r.empty+" !== false && len === 0) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (len !== "+r.items.length+") {\n\t\t\t\t"+this.makeError({type:"tupleLength",expected:r.items.length,actual:"len",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),t.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t"),a=0;a<r.items.length;a++){var s=e+"["+a+"]",i=this.getRuleFromSchema(r.items[a]);t.push(this.compileRule(i,n,s,"\n\t\t\tarr["+a+"] = context.fn[%%INDEX%%](arr["+a+'], (parentField ? parentField : "") + "[" + '+a+' + "]", parent, errors, context);\n\t\t',"arr["+a+"]"))}return t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function u(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)),a="\n\t\t\tif (!"+a.toString()+".test(value))\n\t\t\t\t"+this.makeError({type:"stringPattern",expected:'"'+a.toString().replace(/"/g,"\\$&")+'"',actual:"origValue",messages:t})+"\n\t\t",n.push("\n\t\t\tif ("+e.empty+" === true && len === 0) {\n\t\t\t\t// Do nothing\n\t\t\t} else {\n\t\t\t\t"+a+"\n\t\t\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 (!"+L.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(!"+V.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(!"+R.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 || !"+$.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringHex",actual:"origValue",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.singleLine&&n.push('\n\t\t\tif(value.includes("\\n")) {\n\t\t\t\t'+this.makeError({type:"stringSingleLine",messages:t})+"\n\t\t\t}\n\t\t"),!0===e.base64&&n.push("\n\t\t\tif(!"+U.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringBase64",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 l(t,e,n){e=t.schema;var r=t.messages;t=t.index;var a=[];return n.customs[t]?n.customs[t].schema=e:n.customs[t]={schema:e},a.push("\n\t\tconst ObjectID = context.customs["+t+"].schema.ObjectID;\n\t\tif (!ObjectID.isValid(value)) {\n\t\t\t"+this.makeError({type:"objectID",actual:"value",messages:r})+"\n\t\t\treturn;\n\t\t}\n\t"),!0===e.convert?a.push("return new ObjectID(value)"):"hexString"===e.convert?a.push("return value.toString()"):a.push("return value"),{source:a.join("\n")}}function o(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=j(l),c=P.test(o)?"."+o:"['"+o+"']",p="parentObj"+c,f=(e?e+".":"")+l;a.push("\n// Field: "+j(f)),a.push('field = parentField ? parentField + "'+c+'" : "'+o+'";'),a.push("value = "+p+";"),l=this.getRuleFromSchema(s[l]),a.push(this.compileRule(l,n,f,"\n\t\t\t\t"+p+" = context.fn[%%INDEX%%](value, field, parentObj, errors, context);\n\t\t\t",p))}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"))}return null==r.minProps&&null==r.maxProps||(r.strict?a.push("\n\t\t\t\tprops = Object.keys("+(s?"parentObj":"value")+");\n\t\t\t"):a.push("\n\t\t\t\tvar props = Object.keys("+(s?"parentObj":"value")+");\n\t\t\t\t"+(s?"field = parentField;":"")+"\n\t\t\t")),null!=r.minProps&&a.push("\n\t\t\tif (props.length < "+r.minProps+") {\n\t\t\t\t"+this.makeError({type:"objectMinProps",expected:r.minProps,actual:"props.length",messages:t})+"\n\t\t\t}\n\t\t"),null!=r.maxProps&&a.push("\n\t\t\tif (props.length > "+r.maxProps+") {\n\t\t\t\t"+this.makeError({type:"objectMaxProps",expected:r.maxProps,actual:"props.length",messages:t})+"\n\t\t\t}\n\t\t"),s?a.push("\n\t\t\treturn parentObj;\n\t\t"):a.push("\n\t\t\treturn value;\n\t\t"),{source:a.join("\n")}}function c(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 p(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 h(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 m(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 g(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 d(t){var e=t.schema;t=t.messages;var n=[],r="precise"==e.mode?F:M,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.empty?n.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):n.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\t"+this.makeError({type:"emailEmpty",actual:"value",messages:t})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t"),e.normalize&&(a=!0,n.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t")),null!=e.min&&n.push("\n\t\t\tif (value.length < "+e.min+") {\n\t\t\t\t"+this.makeError({type:"emailMin",expected:e.min,actual:"value.length",messages:t})+"\n\t\t\t}\n\t\t"),null!=e.max&&n.push("\n\t\t\tif (value.length > "+e.max+") {\n\t\t\t\t"+this.makeError({type:"emailMax",expected:e.max,actual:"value.length",messages:t})+"\n\t\t\t}\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 v(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 y(t){var e=t.schema;t=t.messages;var n=e.currencySymbol||null,r=e.thousandSeparator||",",a=e.decimalSeparator||".",s=e.customRegex;return e=!e.symbolOptional,e="(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$".replace(/~1/g,n?"\\"+n+(e?"":"?"):"").replace("~2",r).replace("~3",a),(n=[]).push("\n\t\tif (!value.match("+(s||new RegExp(e))+")) {\n\t\t\t"+this.makeError({type:"currency",actual:"value",messages:t})+"\n\t\t\treturn value;\n\t\t}\n\n\t\treturn value;\n\t"),{source:n.join("\n")}}function b(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,ruleIndex:t.index})+"\n\t\treturn value;\n\t"),{source:r.join("\n")}}function x(t,e,n){e=t.schema;var r=t.messages;t=t.index;var a=[],s=e.instanceOf.name?e.instanceOf.name:"<UnknowClass>";return n.customs[t]?n.customs[t].schema=e:n.customs[t]={schema:e},a.push("\n\t\tif (!(value instanceof context.customs["+t+"].schema.instanceOf))\n\t\t\t"+this.makeError({type:"classInstanceOf",actual:"value",expected:"'"+s+"'",messages:r})+"\n\t"),a.push("\n\t\treturn value;\n\t"),{source:a.join("\n")}}function E(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 S(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),t.push(this.compileRule(r,n,e,'arr[i] = context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context)',"arr[i]")),t.push("\n\t\t\t}\n\t\t")),t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function k(){var t=[];return t.push("\n\t\treturn value;\n\t"),{source:t.join("\n")}}function O(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]||{},O(t[r],e[r],n)):!0===n.skipIfExist&&void 0!==t[r]||(t[r]=e[r])}return t}function j(t){return t.replace(C,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 T(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}var _,A,w,I,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.",stringSingleLine:"The '{field}' field must be a single line string.",stringBase64:"The '{field}' field must be a base64 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.",tuple:"The '{field}' field must be an array.",tupleEmpty:"The '{field}' field must not be an empty array.",tupleLength:"The '{field}' field must contain {expected} items.",boolean:"The '{field}' field must be a boolean.",currency:"The '{field}' must be a valid currency format",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.",emailEmpty:"The '{field}' field must not be empty.",emailMin:"The '{field}' field length must be greater than or equal to {expected} characters long.",emailMax:"The '{field}' field length must be less than or equal to {expected} characters long.",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}'.",objectMinProps:"The object '{field}' must contain at least {expected} properties.",objectMaxProps:"The object '{field}' must contain {expected} properties at most.",url:"The '{field}' field must be a valid URL.",urlEmpty:"The '{field}' field must not be empty.",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.",objectID:"The '{field}' field must be an valid ObjectID"},F=/^(([^<>()[\]\\.,;:\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,}))$/,M=/^\S+@\S+\.\S+$/,P=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/,C=/["'\\\n\r\u2028\u2029]/g,L=/^-?[0-9]\d*(\.\d+)?$/,V=/^[a-zA-Z]+$/,R=/^[a-zA-Z0-9]+$/,q=/^[a-zA-Z0-9_-]+$/,$=/^[0-9a-fA-F]+$/,U=/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+/]{3}=)?$/,D=/^https?:\/\/\S+/,z=/^([0-9a-f]{8}-[0-9a-f]{4}-[1-6][0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}|[0]{8}-[0]{4}-[0]{4}-[0]{4}-[0]{12})$/i,Y=/^((([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,r){var a=[],s=!0===t.schema.optional||"forbidden"===t.schema.type,i=!0===t.schema.optional||!0===t.schema.nullable||"forbidden"===t.schema.type;return null!=t.schema.default?(s=!1,!0!==t.schema.nullable&&(i=!1),"function"==typeof t.schema.default?(n.customs[t.index]||(n.customs[t.index]={}),n.customs[t.index].defaultFn=t.schema.default,t="context.customs["+t.index+"].defaultFn()"):t=JSON.stringify(t.schema.default),r="\n\t\t\t\tvalue = "+t+";\n\t\t\t\t"+r+" = value;\n\t\t\t"):r=this.makeError({type:"required",actual:"value",messages:t.messages}),a.push("\n\t\t\tif (value === undefined) { "+(s?"\n// allow undefined\n":r)+" }\n\t\t\telse if (value === null) { "+(i?"\n// allow null\n":r)+" }\n\t\t\t"+(e?"else { "+e+" }":"")+"\n\t\t"),a.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("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%%/g,t.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",e,a))):(this.cache.set(t.schema,t),t.index=e.index,e.rules[e.index]=t,i=null!=n?n:"$$root",e.index++,n=t.ruleFunction.call(this,t,n,e),n.source=n.source.replace(/%%INDEX%%/g,t.index),n=new Function("value","field","parent","errors","context",n.source),e.fn[t.index]=n,s.push(this.wrapRequiredCheckSourceCode(t,r.replace(/%%INDEX%%/g,t.index),e,a)),s.push(this.makeCustomValidator({vName:a,path:i,schema:t.schema,context:e,messages:t.messages,ruleIndex:t.index}))),s.join("\n")},t.prototype.getRuleFromSchema=function(t){var e=this;if("string"==typeof t)t=this.parseShortHand(t);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(t.$$type){var n=this.getRuleFromSchema(t.$$type).schema;delete t.$$type;var r,a=Object.assign({},t);for(r in t)delete t[r];O(t,n,{skipIfExist:!0}),t.props=a}if((n=this.aliases[t.type])&&(delete t.type,t=O(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:O(t,this.defaults[t.type],{skipIfExist:!0}),ruleFunction:n}},t.prototype.parseShortHand=function(t){var e=(t=t.split("|").map(function(t){return t.trim()}))[0],n=e.endsWith("[]")?this.getRuleFromSchema({type:"array",items:e.slice(0,-2)}).schema:{type:t[0]};return t.slice(1).map(function(t){var e=t.indexOf(":");if(-1!==e){var r=t.substr(0,e).trim();"true"===(t=t.substr(e+1).trim())||"false"===t?t="true"===t:Number.isNaN(Number(t))||(t=Number(t)),n[r]=t}else t.startsWith("no-")?n[t.slice(3)]=!1:n[t]=!0}),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",null!=r&&(s.expected=r),null!=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.ruleIndex,a=t.path,s=t.schema,i=t.context,u=t.messages;t="rule"+r;var l="fnCustomErrors"+r;return"function"==typeof s[n]?(i.customs[r]?(i.customs[r].messages=u,i.customs[r].schema=s):i.customs[r]={messages:u,schema:s},this.opts.useNewCustomCheckerFunction?"\n const "+t+" = context.customs["+r+"];\n\t\t\t\t\tconst "+l+" = [];\n\t\t\t\t\t"+e+" = "+t+".schema."+n+".call(this, "+e+", "+l+" , "+t+'.schema, "'+a+'", parent, context);\n\t\t\t\t\tif (Array.isArray('+l+" )) {\n "+l+" .forEach(err => errors.push(Object.assign({ message: "+t+".messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t":(s="res_"+t,"\n\t\t\t\tconst "+t+" = context.customs["+r+"];\n\t\t\t\tconst "+s+" = "+t+".schema."+n+".call(this, "+e+", "+t+'.schema, "'+a+'", parent, context);\n\t\t\t\tif (Array.isArray('+s+")) {\n\t\t\t\t\t"+s+".forEach(err => errors.push(Object.assign({ message: "+t+".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.addMessage=function(t,e){this.messages[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.prototype.plugin=function(t){if("function"!=typeof t)throw Error("Plugin fn type must be function");return t(this)},t}var g=g||{};g.scope={},g.arrayIteratorImpl=function(t){var e=0;return function(){return e<t.length?{done:!1,value:t[e++]}:{done:!0}}},g.arrayIterator=function(t){return{next:g.arrayIteratorImpl(t)}},g.ASSUME_ES5=!1,g.ASSUME_NO_NATIVE_MAP=!1,g.ASSUME_NO_NATIVE_SET=!1,g.SIMPLE_FROUND_POLYFILL=!1,g.ISOLATE_POLYFILLS=!1,g.defineProperty=g.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(t,e,n){return t==Array.prototype||t==Object.prototype?t:(t[e]=n.value,t)},g.getGlobal=function(t){t=["object"==typeof globalThis&&globalThis,t,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];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")},g.global=g.getGlobal(this),g.IS_SYMBOL_NATIVE="function"==typeof Symbol&&"symbol"==typeof Symbol("x"),g.TRUST_ES6_POLYFILLS=!g.ISOLATE_POLYFILLS||g.IS_SYMBOL_NATIVE,g.polyfills={},g.propertyToPolyfillSymbol={},g.POLYFILL_PREFIX="$jscp$",g.polyfill=function(t,e,n,r){e&&(g.ISOLATE_POLYFILLS?g.polyfillIsolated(t,e,n,r):g.polyfillUnisolated(t,e,n,r))},g.polyfillUnisolated=function(t,e){var n=g.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&&g.defineProperty(n,t,{configurable:!0,writable:!0,value:e})},g.polyfillIsolated=function(t,e,n){var r=t.split(".");t=1===r.length;var a=r[0];a=!t&&a in g.polyfills?g.polyfills:g.global;for(var s=0;s<r.length-1;s++){var i=r[s];i in a||(a[i]={}),a=a[i]}r=r[r.length-1],null!=(e=e(n=g.IS_SYMBOL_NATIVE&&"es6"===n?a[r]:null))&&(t?g.defineProperty(g.polyfills,r,{configurable:!0,writable:!0,value:e}):e!==n&&(g.propertyToPolyfillSymbol[r]=g.IS_SYMBOL_NATIVE?g.global.Symbol(r):g.POLYFILL_PREFIX+r,r=g.propertyToPolyfillSymbol[r],g.defineProperty(a,r,{configurable:!0,writable:!0,value:e})))},g.initSymbol=function(){},g.polyfill("Symbol",function(t){function e(t){if(this instanceof e)throw new TypeError("Symbol is not a constructor");return new n("jscomp_symbol_"+(t||"")+"_"+r++,t)}function n(t,e){this.$jscomp$symbol$id_=t,g.defineProperty(this,"description",{configurable:!0,writable:!0,value:e})}if(t)return t;n.prototype.toString=function(){return this.$jscomp$symbol$id_};var r=0;return e},"es6","es3"),g.initSymbolIterator=function(){},g.polyfill("Symbol.iterator",function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var e="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),n=0;n<e.length;n++){var r=g.global[e[n]];"function"==typeof r&&"function"!=typeof r.prototype[t]&&g.defineProperty(r.prototype,t,{configurable:!0,writable:!0,value:function(){return g.iteratorPrototype(g.arrayIteratorImpl(this))}})}return t},"es6","es3"),g.initSymbolAsyncIterator=function(){},g.iteratorPrototype=function(t){return t={next:t},t[Symbol.iterator]=function(){return this},t},g.iteratorFromArray=function(t,e){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},g.polyfill("Array.prototype.keys",function(t){return t||function(){return g.iteratorFromArray(this,function(t){return t})}},"es6","es3"),g.polyfill("Array.prototype.values",function(t){return t||function(){return g.iteratorFromArray(this,function(t,e){return e})}},"es8","es3"),g.owns=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},g.assign=g.TRUST_ES6_POLYFILLS&&"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)g.owns(r,a)&&(t[a]=r[a])}return t},g.polyfill("Object.assign",function(t){return t||g.assign},"es6","es3"),g.checkEs6ConformanceViaProxy=function(){try{var t={},e=Object.create(new g.global.Proxy(t,{get:function(n,r,a){return n==t&&"q"==r&&a==e}}));return!0===e.q}catch(t){return!1}},g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1,g.ES6_CONFORMANCE=g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&g.checkEs6ConformanceViaProxy(),g.makeIterator=function(t){var e="undefined"!=typeof Symbol&&Symbol.iterator&&t[Symbol.iterator];return e?e.call(t):g.arrayIterator(t)},g.polyfill("WeakMap",function(t){function e(t){if(this.id_=(u+=Math.random()+1).toString(),t){t=g.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(!g.owns(t,i)){var e=new n;g.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(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&g.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),!g.owns(t,i))throw Error("WeakMap key fail: "+t);return t[i][this.id_]=e,this},e.prototype.get=function(t){return r(t)&&g.owns(t,i)?t[i][this.id_]:void 0},e.prototype.has=function(t){return r(t)&&g.owns(t,i)&&g.owns(t[i],this.id_)},e.prototype.delete=function(t){return!!(r(t)&&g.owns(t,i)&&g.owns(t[i],this.id_))&&delete t[i][this.id_]},e},"es6","es3"),g.MapEntry=function(){},g.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 g.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&&g.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=g.makeIterator(t);for(var n;!(n=t.next()).done;)n=n.value,this.set(n[0],n[1])}}if(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(t&&g.ES6_CONFORMANCE)return t}else if(function(){if(g.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(g.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;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"),g.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+""},g.polyfill("String.prototype.endsWith",function(t){return t||function(t,e){var n=g.checkStringArgs(this,t,"endsWith");t+="",void 0===e&&(e=n.length),e=Math.max(0,Math.min(0|e,n.length));for(var r=t.length;0<r&&0<e;)if(n[--e]!=t[--r])return!1;return 0>=r}},"es6","es3"),g.polyfill("Number.isNaN",function(t){return t||function(t){return"number"==typeof t&&isNaN(t)}},"es6","es3"),g.polyfill("String.prototype.startsWith",function(t){return t||function(t,e){var n=g.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 u=this;"object"==typeof exports&&"undefined"!=typeof module?module.exports=v():"function"==typeof define&&define.amd?define(v):(u=u||self,u.FastestValidator=v()); |
"use strict"; | ||
const CURRENCY_REGEX = `(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$`; | ||
const CURRENCY_REGEX = "(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$"; | ||
/** Signature: function(value, field, parent, errors, context) | ||
@@ -8,21 +8,25 @@ */ | ||
const currencySymbol = schema.currencySymbol || null; | ||
const thousandSeparator = schema.thousandSeparator || ','; | ||
const decimalSeparator = schema.decimalSeparator || '.'; | ||
const thousandSeparator = schema.thousandSeparator || ","; | ||
const decimalSeparator = schema.decimalSeparator || "."; | ||
const customRegex = schema.customRegex; | ||
let isCurrencySymbolMandatory = !schema.symbolOptional; | ||
let finalRegex = CURRENCY_REGEX.replace(/~1/g, currencySymbol ? (`\\${currencySymbol}${(isCurrencySymbolMandatory ? '' : '?')}`) : '') | ||
.replace('~2', thousandSeparator) | ||
.replace('~3', decimalSeparator); | ||
let finalRegex = CURRENCY_REGEX.replace(/~1/g, currencySymbol ? (`\\${currencySymbol}${(isCurrencySymbolMandatory ? "" : "?")}`) : "") | ||
.replace("~2", thousandSeparator) | ||
.replace("~3", decimalSeparator); | ||
const src = []; | ||
src.push(` | ||
if (!value.match(${customRegex || new RegExp(finalRegex)})) { | ||
${this.makeError({ type: "currency", actual: "value", messages })} | ||
return value; | ||
} | ||
return value; | ||
`); | ||
return { | ||
source: ` | ||
if (!value.match(${customRegex || new RegExp(finalRegex)})){ | ||
return ${this.makeError({ | ||
type: "currency", | ||
actual: "value", | ||
messages | ||
})} | ||
} | ||
return value; | ||
` | ||
source: src.join("\n") | ||
}; | ||
}; |
@@ -24,3 +24,4 @@ "use strict"; | ||
if (value.length === 0) { | ||
return ${this.makeError({ type: "emailEmpty", actual: "value", messages })} | ||
${this.makeError({ type: "emailEmpty", actual: "value", messages })} | ||
return value; | ||
} | ||
@@ -27,0 +28,0 @@ `); |
@@ -142,3 +142,3 @@ "use strict"; | ||
if (!${pattern.toString()}.test(value)) | ||
${this.makeError({ type: "stringPattern", expected: "\"" + pattern.toString().replace("\"", "\\\"") + "\"", actual: "origValue", messages })} | ||
${this.makeError({ type: "stringPattern", expected: `"${pattern.toString().replace(/"/g, "\\$&")}"`, actual: "origValue", messages })} | ||
`; | ||
@@ -145,0 +145,0 @@ |
@@ -22,3 +22,4 @@ "use strict"; | ||
if (value.length === 0) { | ||
return ${this.makeError({ type: "urlEmpty", actual: "value", messages })} | ||
${this.makeError({ type: "urlEmpty", actual: "value", messages })} | ||
return value; | ||
} | ||
@@ -25,0 +26,0 @@ `); |
{ | ||
"name": "fastest-validator", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "The fastest JS validator library for NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -192,4 +192,6 @@ ![Photos from @ikukevk](https://user-images.githubusercontent.com/306521/30183963-9c722dca-941c-11e7-9e83-c78377ad7f9d.jpg) | ||
### Deno usage | ||
With `esm.sh`, now Typescript is supported | ||
```js | ||
import FastestValidator from "https://dev.jspm.io/fastest-validator"; | ||
import FastestValidator from "https://esm.sh/fastest-validator@1" | ||
@@ -1212,4 +1214,4 @@ const v = new FastestValidator(); | ||
name: { type: "string", min: 3, max: 255 }, | ||
phone: { type: "string", length: 15, custom(v, errors) => { | ||
if (!v.startWith("+")) errors.push({ type: "phoneNumber" }) | ||
phone: { type: "string", length: 15, custom: (v, errors) => { | ||
if (!v.startsWith("+")) errors.push({ type: "phoneNumber" }) | ||
return v.replace(/[^\d+]/g, ""); // Sanitize: remove all special chars except numbers | ||
@@ -1216,0 +1218,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351352
1443