Socket
Socket
Sign inDemoInstall

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.16.0 to 1.17.0

CHANGELOG.md

10

dist/index.d.ts

@@ -911,2 +911,12 @@

/**
* consider null as a value?
*/
considerNullAsAValue?: boolean;
/**
* Immediately halt after the first error
*/
haltOnFirstError?: boolean
/**
* Default settings for rules

@@ -913,0 +923,0 @@ */

27

dist/index.js

@@ -1180,11 +1180,23 @@ (function (global, factory) {

var src = [];
var ref = this.opts;
var considerNullAsAValue = ref.considerNullAsAValue; if ( considerNullAsAValue === void 0 ) considerNullAsAValue = false;
var handleNoValue;
var skipUndefinedValue = rule.schema.optional === true || rule.schema.type === "forbidden";
var skipNullValue = rule.schema.optional === true || rule.schema.nullable === true || rule.schema.type === "forbidden";
var skipNullValue = considerNullAsAValue ?
rule.schema.nullable !== false || rule.schema.type === "forbidden" :
rule.schema.optional === true || rule.schema.nullable === true || rule.schema.type === "forbidden";
if (rule.schema.default != null) {
var ruleHasDefault = considerNullAsAValue ?
rule.schema.default != undefined && rule.schema.default != null :
rule.schema.default != undefined;
if (ruleHasDefault) {
// We should set default-value when value is undefined or null, not skip! (Except when null is allowed)
skipUndefinedValue = false;
if (rule.schema.nullable !== true) { skipNullValue = false; }
if (considerNullAsAValue) {
if (rule.schema.nullable === false) { skipNullValue = false; }
} else {
if (rule.schema.nullable !== true) { skipNullValue = false; }
}

@@ -1551,7 +1563,8 @@ var defaultValue;

// Check 'nullable' flag
var isNullable = schema.rules
var nullCheck = this.opts.considerNullAsAValue ? false : true;
var setNullable = schema.rules
.map(function (s) { return this$1$1.getRuleFromSchema(s); })
.every(function (rule) { return rule.schema.nullable === true; });
if (isNullable)
{ schema.nullable = true; }
.every(function (rule) { return rule.schema.nullable === nullCheck; });
if (setNullable)
{ schema.nullable = nullCheck; }
}

@@ -1558,0 +1571,0 @@

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

'use strict';var g=g||{};g.scope={};g.arrayIteratorImpl=function(f){var h=0;return function(){return h<f.length?{done:!1,value:f[h++]}:{done:!0}}};g.arrayIterator=function(f){return{next:g.arrayIteratorImpl(f)}};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.FORCE_POLYFILL_PROMISE=!1;g.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;
g.defineProperty=g.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(f,h,l){if(f==Array.prototype||f==Object.prototype)return f;f[h]=l.value;return f};g.getGlobal=function(f){f=["object"==typeof globalThis&&globalThis,f,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var h=0;h<f.length;++h){var l=f[h];if(l&&l.Math==Math)return l}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(f,h,l,m){h&&(g.ISOLATE_POLYFILLS?g.polyfillIsolated(f,h,l,m):g.polyfillUnisolated(f,h,l,m))};
g.polyfillUnisolated=function(f,h){var l=g.global;f=f.split(".");for(var m=0;m<f.length-1;m++){var t=f[m];if(!(t in l))return;l=l[t]}f=f[f.length-1];m=l[f];h=h(m);h!=m&&null!=h&&g.defineProperty(l,f,{configurable:!0,writable:!0,value:h})};
g.polyfillIsolated=function(f,h,l){var m=f.split(".");f=1===m.length;var t=m[0];t=!f&&t in g.polyfills?g.polyfills:g.global;for(var w=0;w<m.length-1;w++){var x=m[w];if(!(x in t))return;t=t[x]}m=m[m.length-1];l=g.IS_SYMBOL_NATIVE&&"es6"===l?t[m]:null;h=h(l);null!=h&&(f?g.defineProperty(g.polyfills,m,{configurable:!0,writable:!0,value:h}):h!==l&&(void 0===g.propertyToPolyfillSymbol[m]&&(f=1E9*Math.random()>>>0,g.propertyToPolyfillSymbol[m]=g.IS_SYMBOL_NATIVE?g.global.Symbol(m):g.POLYFILL_PREFIX+f+"$"+
'use strict';var g=g||{};g.scope={};g.arrayIteratorImpl=function(e){var h=0;return function(){return h<e.length?{done:!1,value:e[h++]}:{done:!0}}};g.arrayIterator=function(e){return{next:g.arrayIteratorImpl(e)}};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.FORCE_POLYFILL_PROMISE=!1;g.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;
g.defineProperty=g.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(e,h,l){if(e==Array.prototype||e==Object.prototype)return e;e[h]=l.value;return e};g.getGlobal=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var h=0;h<e.length;++h){var l=e[h];if(l&&l.Math==Math)return l}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(e,h,l,m){h&&(g.ISOLATE_POLYFILLS?g.polyfillIsolated(e,h,l,m):g.polyfillUnisolated(e,h,l,m))};
g.polyfillUnisolated=function(e,h){var l=g.global;e=e.split(".");for(var m=0;m<e.length-1;m++){var t=e[m];if(!(t in l))return;l=l[t]}e=e[e.length-1];m=l[e];h=h(m);h!=m&&null!=h&&g.defineProperty(l,e,{configurable:!0,writable:!0,value:h})};
g.polyfillIsolated=function(e,h,l){var m=e.split(".");e=1===m.length;var t=m[0];t=!e&&t in g.polyfills?g.polyfills:g.global;for(var w=0;w<m.length-1;w++){var x=m[w];if(!(x in t))return;t=t[x]}m=m[m.length-1];l=g.IS_SYMBOL_NATIVE&&"es6"===l?t[m]:null;h=h(l);null!=h&&(e?g.defineProperty(g.polyfills,m,{configurable:!0,writable:!0,value:h}):h!==l&&(void 0===g.propertyToPolyfillSymbol[m]&&(e=1E9*Math.random()>>>0,g.propertyToPolyfillSymbol[m]=g.IS_SYMBOL_NATIVE?g.global.Symbol(m):g.POLYFILL_PREFIX+e+"$"+
m),g.defineProperty(t,g.propertyToPolyfillSymbol[m],{configurable:!0,writable:!0,value:h})))};g.initSymbol=function(){};
g.polyfill("Symbol",function(f){function h(w){if(this instanceof h)throw new TypeError("Symbol is not a constructor");return new l(m+(w||"")+"_"+t++,w)}function l(w,x){this.$jscomp$symbol$id_=w;g.defineProperty(this,"description",{configurable:!0,writable:!0,value:x})}if(f)return f;l.prototype.toString=function(){return this.$jscomp$symbol$id_};var m="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",t=0;return h},"es6","es3");
g.polyfill("Symbol.iterator",function(f){if(f)return f;f=Symbol("Symbol.iterator");for(var h="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),l=0;l<h.length;l++){var m=g.global[h[l]];"function"===typeof m&&"function"!=typeof m.prototype[f]&&g.defineProperty(m.prototype,f,{configurable:!0,writable:!0,value:function(){return g.iteratorPrototype(g.arrayIteratorImpl(this))}})}return f},"es6","es3");
g.iteratorPrototype=function(f){f={next:f};f[Symbol.iterator]=function(){return this};return f};g.iteratorFromArray=function(f,h){f instanceof String&&(f+="");var l=0,m=!1,t={next:function(){if(!m&&l<f.length){var w=l++;return{value:h(w,f[w]),done:!1}}m=!0;return{done:!0,value:void 0}}};t[Symbol.iterator]=function(){return t};return t};g.polyfill("Array.prototype.keys",function(f){return f?f:function(){return g.iteratorFromArray(this,function(h){return h})}},"es6","es3");
g.polyfill("Array.prototype.values",function(f){return f?f:function(){return g.iteratorFromArray(this,function(h,l){return l})}},"es8","es3");g.checkStringArgs=function(f,h,l){if(null==f)throw new TypeError("The 'this' value for String.prototype."+l+" must not be null or undefined");if(h instanceof RegExp)throw new TypeError("First argument to String.prototype."+l+" must not be a regular expression");return f+""};
g.polyfill("String.prototype.startsWith",function(f){return f?f:function(h,l){var m=g.checkStringArgs(this,h,"startsWith");h+="";var t=m.length,w=h.length;l=Math.max(0,Math.min(l|0,m.length));for(var x=0;x<w&&l<t;)if(m[l++]!=h[x++])return!1;return x>=w}},"es6","es3");g.owns=function(f,h){return Object.prototype.hasOwnProperty.call(f,h)};
g.assign=g.TRUST_ES6_POLYFILLS&&"function"==typeof Object.assign?Object.assign:function(f,h){for(var l=1;l<arguments.length;l++){var m=arguments[l];if(m)for(var t in m)g.owns(m,t)&&(f[t]=m[t])}return f};g.polyfill("Object.assign",function(f){return f||g.assign},"es6","es3");g.checkEs6ConformanceViaProxy=function(){try{var f={},h=Object.create(new g.global.Proxy(f,{get:function(l,m,t){return l==f&&"q"==m&&t==h}}));return!0===h.q}catch(l){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(f){var h="undefined"!=typeof Symbol&&Symbol.iterator&&f[Symbol.iterator];return h?h.call(f):g.arrayIterator(f)};
g.polyfill("WeakMap",function(f){function h(k){this.id_=(n+=Math.random()+1).toString();if(k){k=g.makeIterator(k);for(var q;!(q=k.next()).done;)q=q.value,this.set(q[0],q[1])}}function l(){if(!f||!Object.seal)return!1;try{var k=Object.seal({}),q=Object.seal({}),u=new f([[k,2],[q,3]]);if(2!=u.get(k)||3!=u.get(q))return!1;u.delete(k);u.set(q,4);return!u.has(k)&&4==u.get(q)}catch(C){return!1}}function m(){}function t(k){var q=typeof k;return"object"===q&&null!==k||"function"===q}function w(k){if(!g.owns(k,
y)){var q=new m;g.defineProperty(k,y,{value:q})}}function x(k){if(!g.ISOLATE_POLYFILLS){var q=Object[k];q&&(Object[k]=function(u){if(u instanceof m)return u;Object.isExtensible(u)&&w(u);return q(u)})}}if(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(f&&g.ES6_CONFORMANCE)return f}else if(l())return f;var y="$jscomp_hidden_"+Math.random();x("freeze");x("preventExtensions");x("seal");var n=0;h.prototype.set=function(k,q){if(!t(k))throw Error("Invalid WeakMap key");w(k);if(!g.owns(k,y))throw Error("WeakMap key fail: "+
k);k[y][this.id_]=q;return this};h.prototype.get=function(k){return t(k)&&g.owns(k,y)?k[y][this.id_]:void 0};h.prototype.has=function(k){return t(k)&&g.owns(k,y)&&g.owns(k[y],this.id_)};h.prototype.delete=function(k){return t(k)&&g.owns(k,y)&&g.owns(k[y],this.id_)?delete k[y][this.id_]:!1};return h},"es6","es3");g.MapEntry=function(){};
g.polyfill("Map",function(f){function h(){var n={};return n.previous=n.next=n.head=n}function l(n,k){var q=n.head_;return g.iteratorPrototype(function(){if(q){for(;q.head!=n.head_;)q=q.previous;for(;q.next!=q.head;)return q=q.next,{done:!1,value:k(q)};q=null}return{done:!0,value:void 0}})}function m(n,k){var q=k&&typeof k;"object"==q||"function"==q?x.has(k)?q=x.get(k):(q=""+ ++y,x.set(k,q)):q="p_"+k;var u=n.data_[q];if(u&&g.owns(n.data_,q))for(n=0;n<u.length;n++){var C=u[n];if(k!==k&&C.key!==C.key||
k===C.key)return{id:q,list:u,index:n,entry:C}}return{id:q,list:u,index:-1,entry:void 0}}function t(n){this.data_={};this.head_=h();this.size=0;if(n){n=g.makeIterator(n);for(var k;!(k=n.next()).done;)k=k.value,this.set(k[0],k[1])}}function w(){if(g.ASSUME_NO_NATIVE_MAP||!f||"function"!=typeof f||!f.prototype.entries||"function"!=typeof Object.seal)return!1;try{var n=Object.seal({x:4}),k=new f(g.makeIterator([[n,"s"]]));if("s"!=k.get(n)||1!=k.size||k.get({x:4})||k.set({x:4},"t")!=k||2!=k.size)return!1;
var q=k.entries(),u=q.next();if(u.done||u.value[0]!=n||"s"!=u.value[1])return!1;u=q.next();return u.done||4!=u.value[0].x||"t"!=u.value[1]||!q.next().done?!1:!0}catch(C){return!1}}if(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(f&&g.ES6_CONFORMANCE)return f}else if(w())return f;var x=new WeakMap;t.prototype.set=function(n,k){n=0===n?0:n;var q=m(this,n);q.list||(q.list=this.data_[q.id]=[]);q.entry?q.entry.value=k:(q.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:n,value:k},q.list.push(q.entry),
this.head_.previous.next=q.entry,this.head_.previous=q.entry,this.size++);return this};t.prototype.delete=function(n){n=m(this,n);return n.entry&&n.list?(n.list.splice(n.index,1),n.list.length||delete this.data_[n.id],n.entry.previous.next=n.entry.next,n.entry.next.previous=n.entry.previous,n.entry.head=null,this.size--,!0):!1};t.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=h();this.size=0};t.prototype.has=function(n){return!!m(this,n).entry};t.prototype.get=function(n){return(n=
m(this,n).entry)&&n.value};t.prototype.entries=function(){return l(this,function(n){return[n.key,n.value]})};t.prototype.keys=function(){return l(this,function(n){return n.key})};t.prototype.values=function(){return l(this,function(n){return n.value})};t.prototype.forEach=function(n,k){for(var q=this.entries(),u;!(u=q.next()).done;)u=u.value,n.call(k,u[1],u[0],this)};t.prototype[Symbol.iterator]=t.prototype.entries;var y=0;return t},"es6","es3");
g.polyfill("String.prototype.endsWith",function(f){return f?f:function(h,l){var m=g.checkStringArgs(this,h,"endsWith");h+="";void 0===l&&(l=m.length);l=Math.max(0,Math.min(l|0,m.length));for(var t=h.length;0<t&&0<l;)if(m[--l]!=h[--t])return!1;return 0>=t}},"es6","es3");g.polyfill("Number.isNaN",function(f){return f?f:function(h){return"number"===typeof h&&isNaN(h)}},"es6","es3");
g.polyfill("Object.entries",function(f){return f?f:function(h){var l=[],m;for(m in h)g.owns(h,m)&&l.push([m,h[m]]);return l}},"es8","es3");var F=this;
function G(){function f(a){this.opts={};this.defaults={};this.messages=Object.assign({},r);this.rules={any:R,array:S,boolean:T,class:U,custom:V,currency:W,date:X,email:Y,enum:Z,equal:aa,forbidden:ba,function:ca,multi:C,number:u,object:q,objectID:k,record:n,string:y,tuple:x,url:w,uuid:t,mac:m,luhn:l};this.aliases={};this.cache=new Map;if(a){B(this.opts,a);a.defaults&&B(this.defaults,a.defaults);if(a.messages)for(var b in a.messages)this.addMessage(b,a.messages[b]);if(a.aliases)for(var c in a.aliases)this.alias(c,
a.aliases[c]);if(a.customRules)for(var d in a.customRules)this.add(d,a.customRules[d]);if(a.plugins){a=a.plugins;if(!Array.isArray(a))throw Error("Plugins type must be array");a.forEach(this.plugin.bind(this))}this.opts.debug&&(a=function(e){return e},"undefined"===typeof window&&(a=h),this._formatter=a)}}function h(a){H||(H=M(),N={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},I=M(),O={language:"js",theme:I.fromJson({keyword:["white",
g.polyfill("Symbol",function(e){function h(w){if(this instanceof h)throw new TypeError("Symbol is not a constructor");return new l(m+(w||"")+"_"+t++,w)}function l(w,x){this.$jscomp$symbol$id_=w;g.defineProperty(this,"description",{configurable:!0,writable:!0,value:x})}if(e)return e;l.prototype.toString=function(){return this.$jscomp$symbol$id_};var m="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",t=0;return h},"es6","es3");
g.polyfill("Symbol.iterator",function(e){if(e)return e;e=Symbol("Symbol.iterator");for(var h="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),l=0;l<h.length;l++){var m=g.global[h[l]];"function"===typeof m&&"function"!=typeof m.prototype[e]&&g.defineProperty(m.prototype,e,{configurable:!0,writable:!0,value:function(){return g.iteratorPrototype(g.arrayIteratorImpl(this))}})}return e},"es6","es3");
g.iteratorPrototype=function(e){e={next:e};e[Symbol.iterator]=function(){return this};return e};g.iteratorFromArray=function(e,h){e instanceof String&&(e+="");var l=0,m=!1,t={next:function(){if(!m&&l<e.length){var w=l++;return{value:h(w,e[w]),done:!1}}m=!0;return{done:!0,value:void 0}}};t[Symbol.iterator]=function(){return t};return t};g.polyfill("Array.prototype.keys",function(e){return e?e:function(){return g.iteratorFromArray(this,function(h){return h})}},"es6","es3");
g.polyfill("Array.prototype.values",function(e){return e?e:function(){return g.iteratorFromArray(this,function(h,l){return l})}},"es8","es3");g.checkStringArgs=function(e,h,l){if(null==e)throw new TypeError("The 'this' value for String.prototype."+l+" must not be null or undefined");if(h instanceof RegExp)throw new TypeError("First argument to String.prototype."+l+" must not be a regular expression");return e+""};
g.polyfill("String.prototype.startsWith",function(e){return e?e:function(h,l){var m=g.checkStringArgs(this,h,"startsWith");h+="";var t=m.length,w=h.length;l=Math.max(0,Math.min(l|0,m.length));for(var x=0;x<w&&l<t;)if(m[l++]!=h[x++])return!1;return x>=w}},"es6","es3");g.owns=function(e,h){return Object.prototype.hasOwnProperty.call(e,h)};
g.assign=g.TRUST_ES6_POLYFILLS&&"function"==typeof Object.assign?Object.assign:function(e,h){for(var l=1;l<arguments.length;l++){var m=arguments[l];if(m)for(var t in m)g.owns(m,t)&&(e[t]=m[t])}return e};g.polyfill("Object.assign",function(e){return e||g.assign},"es6","es3");g.checkEs6ConformanceViaProxy=function(){try{var e={},h=Object.create(new g.global.Proxy(e,{get:function(l,m,t){return l==e&&"q"==m&&t==h}}));return!0===h.q}catch(l){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(e){var h="undefined"!=typeof Symbol&&Symbol.iterator&&e[Symbol.iterator];return h?h.call(e):g.arrayIterator(e)};
g.polyfill("WeakMap",function(e){function h(k){this.id_=(n+=Math.random()+1).toString();if(k){k=g.makeIterator(k);for(var p;!(p=k.next()).done;)p=p.value,this.set(p[0],p[1])}}function l(){if(!e||!Object.seal)return!1;try{var k=Object.seal({}),p=Object.seal({}),v=new e([[k,2],[p,3]]);if(2!=v.get(k)||3!=v.get(p))return!1;v.delete(k);v.set(p,4);return!v.has(k)&&4==v.get(p)}catch(C){return!1}}function m(){}function t(k){var p=typeof k;return"object"===p&&null!==k||"function"===p}function w(k){if(!g.owns(k,
y)){var p=new m;g.defineProperty(k,y,{value:p})}}function x(k){if(!g.ISOLATE_POLYFILLS){var p=Object[k];p&&(Object[k]=function(v){if(v instanceof m)return v;Object.isExtensible(v)&&w(v);return p(v)})}}if(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(e&&g.ES6_CONFORMANCE)return e}else if(l())return e;var y="$jscomp_hidden_"+Math.random();x("freeze");x("preventExtensions");x("seal");var n=0;h.prototype.set=function(k,p){if(!t(k))throw Error("Invalid WeakMap key");w(k);if(!g.owns(k,y))throw Error("WeakMap key fail: "+
k);k[y][this.id_]=p;return this};h.prototype.get=function(k){return t(k)&&g.owns(k,y)?k[y][this.id_]:void 0};h.prototype.has=function(k){return t(k)&&g.owns(k,y)&&g.owns(k[y],this.id_)};h.prototype.delete=function(k){return t(k)&&g.owns(k,y)&&g.owns(k[y],this.id_)?delete k[y][this.id_]:!1};return h},"es6","es3");g.MapEntry=function(){};
g.polyfill("Map",function(e){function h(){var n={};return n.previous=n.next=n.head=n}function l(n,k){var p=n.head_;return g.iteratorPrototype(function(){if(p){for(;p.head!=n.head_;)p=p.previous;for(;p.next!=p.head;)return p=p.next,{done:!1,value:k(p)};p=null}return{done:!0,value:void 0}})}function m(n,k){var p=k&&typeof k;"object"==p||"function"==p?x.has(k)?p=x.get(k):(p=""+ ++y,x.set(k,p)):p="p_"+k;var v=n.data_[p];if(v&&g.owns(n.data_,p))for(n=0;n<v.length;n++){var C=v[n];if(k!==k&&C.key!==C.key||
k===C.key)return{id:p,list:v,index:n,entry:C}}return{id:p,list:v,index:-1,entry:void 0}}function t(n){this.data_={};this.head_=h();this.size=0;if(n){n=g.makeIterator(n);for(var k;!(k=n.next()).done;)k=k.value,this.set(k[0],k[1])}}function w(){if(g.ASSUME_NO_NATIVE_MAP||!e||"function"!=typeof e||!e.prototype.entries||"function"!=typeof Object.seal)return!1;try{var n=Object.seal({x:4}),k=new e(g.makeIterator([[n,"s"]]));if("s"!=k.get(n)||1!=k.size||k.get({x:4})||k.set({x:4},"t")!=k||2!=k.size)return!1;
var p=k.entries(),v=p.next();if(v.done||v.value[0]!=n||"s"!=v.value[1])return!1;v=p.next();return v.done||4!=v.value[0].x||"t"!=v.value[1]||!p.next().done?!1:!0}catch(C){return!1}}if(g.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(e&&g.ES6_CONFORMANCE)return e}else if(w())return e;var x=new WeakMap;t.prototype.set=function(n,k){n=0===n?0:n;var p=m(this,n);p.list||(p.list=this.data_[p.id]=[]);p.entry?p.entry.value=k:(p.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:n,value:k},p.list.push(p.entry),
this.head_.previous.next=p.entry,this.head_.previous=p.entry,this.size++);return this};t.prototype.delete=function(n){n=m(this,n);return n.entry&&n.list?(n.list.splice(n.index,1),n.list.length||delete this.data_[n.id],n.entry.previous.next=n.entry.next,n.entry.next.previous=n.entry.previous,n.entry.head=null,this.size--,!0):!1};t.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=h();this.size=0};t.prototype.has=function(n){return!!m(this,n).entry};t.prototype.get=function(n){return(n=
m(this,n).entry)&&n.value};t.prototype.entries=function(){return l(this,function(n){return[n.key,n.value]})};t.prototype.keys=function(){return l(this,function(n){return n.key})};t.prototype.values=function(){return l(this,function(n){return n.value})};t.prototype.forEach=function(n,k){for(var p=this.entries(),v;!(v=p.next()).done;)v=v.value,n.call(k,v[1],v[0],this)};t.prototype[Symbol.iterator]=t.prototype.entries;var y=0;return t},"es6","es3");
g.polyfill("String.prototype.endsWith",function(e){return e?e:function(h,l){var m=g.checkStringArgs(this,h,"endsWith");h+="";void 0===l&&(l=m.length);l=Math.max(0,Math.min(l|0,m.length));for(var t=h.length;0<t&&0<l;)if(m[--l]!=h[--t])return!1;return 0>=t}},"es6","es3");g.polyfill("Number.isNaN",function(e){return e?e:function(h){return"number"===typeof h&&isNaN(h)}},"es6","es3");
g.polyfill("Object.entries",function(e){return e?e:function(h){var l=[],m;for(m in h)g.owns(h,m)&&l.push([m,h[m]]);return l}},"es8","es3");var F=this;
function G(){function e(a){this.opts={};this.defaults={};this.messages=Object.assign({},q);this.rules={any:R,array:S,boolean:T,class:U,custom:V,currency:W,date:X,email:Y,enum:Z,equal:aa,forbidden:ba,function:ca,multi:C,number:v,object:p,objectID:k,record:n,string:y,tuple:x,url:w,uuid:t,mac:m,luhn:l};this.aliases={};this.cache=new Map;if(a){B(this.opts,a);a.defaults&&B(this.defaults,a.defaults);if(a.messages)for(var b in a.messages)this.addMessage(b,a.messages[b]);if(a.aliases)for(var c in a.aliases)this.alias(c,
a.aliases[c]);if(a.customRules)for(var d in a.customRules)this.add(d,a.customRules[d]);if(a.plugins){a=a.plugins;if(!Array.isArray(a))throw Error("Plugins type must be array");a.forEach(this.plugin.bind(this))}this.opts.debug&&(a=function(f){return f},"undefined"===typeof window&&(a=h),this._formatter=a)}}function h(a){H||(H=M(),N={parser:"babel",useTabs:!1,printWidth:120,trailingComma:"none",tabWidth:4,singleQuote:!1,semi:!0,bracketSpacing:!0},I=M(),O={language:"js",theme:I.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"})});a=H.format(a,N);return I.highlight(a,O)}function l(a){a.schema;a=a.messages;return{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:a})+'\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'+

@@ -31,24 +31,24 @@ this.makeError({type:"luhn",actual:"value",messages:a})+"\n\t\t\t}\n\n\t\t\treturn value;\n\t\t"}}function m(a){a.schema;a=a.messages;return{source:'\n\t\t\tif (typeof value !== "string") {\n\t\t\t\t'+this.makeError({type:"string",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tvar v = value.toLowerCase();\n\t\t\tif (!"+da.toString()+".test(v)) {\n\t\t\t\t"+this.makeError({type:"mac",actual:"value",messages:a})+"\n\t\t\t}\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function t(a){var b=

this.makeError({type:"string",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");b.empty?c.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):c.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\t"+this.makeError({type:"urlEmpty",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");c.push("\n\t\tif (!"+fa.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"url",actual:"value",messages:a})+"\n\t\t}\n\n\t\treturn value;\n\t");return{source:c.join("\n")}}function x(a,
b,c){var d=a.schema,e=a.messages;a=[];if(null!=d.items){if(!Array.isArray(d.items))throw Error("Invalid '"+d.type+"' schema. The 'items' field must be an array.");if(0===d.items.length)throw Error("Invalid '"+d.type+"' schema. The 'items' field must not be an empty array.");}a.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"tuple",actual:"value",messages:e})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t");!1===d.empty&&a.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+
this.makeError({type:"tupleEmpty",actual:"value",messages:e})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");if(null!=d.items){a.push("\n\t\t\tif ("+d.empty+" !== false && len === 0) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (len !== "+d.items.length+") {\n\t\t\t\t"+this.makeError({type:"tupleLength",expected:d.items.length,actual:"len",messages:e})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");a.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t");for(e=0;e<d.items.length;e++){a.push("\n\t\t\tvalue = arr["+
e+"];\n\t\t");var p=b+"["+e+"]",v=this.getRuleFromSchema(d.items[e]);a.push(this.compileRule(v,c,p,"\n\t\t\tarr["+e+"] = "+(c.async?"await ":"")+"context.fn[%%INDEX%%](arr["+e+'], (parentField ? parentField : "") + "[" + '+e+' + "]", parent, errors, context);\n\t\t',"arr["+e+"]"))}a.push("\n\t\treturn arr;\n\t")}else a.push("\n\t\treturn value;\n\t");return{source:a.join("\n")}}function y(a){var b=a.schema;a=a.messages;var c=[],d=!1;!0===b.convert&&(d=!0,c.push('\n\t\t\tif (typeof value !== "string") {\n\t\t\t\tvalue = String(value);\n\t\t\t}\n\t\t'));
b,c){var d=a.schema,f=a.messages;a=[];if(null!=d.items){if(!Array.isArray(d.items))throw Error("Invalid '"+d.type+"' schema. The 'items' field must be an array.");if(0===d.items.length)throw Error("Invalid '"+d.type+"' schema. The 'items' field must not be an empty array.");}a.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"tuple",actual:"value",messages:f})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t");!1===d.empty&&a.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+
this.makeError({type:"tupleEmpty",actual:"value",messages:f})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");if(null!=d.items){a.push("\n\t\t\tif ("+d.empty+" !== false && len === 0) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tif (len !== "+d.items.length+") {\n\t\t\t\t"+this.makeError({type:"tupleLength",expected:d.items.length,actual:"len",messages:f})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");a.push("\n\t\t\tvar arr = value;\n\t\t\tvar parentField = field;\n\t\t");for(f=0;f<d.items.length;f++){a.push("\n\t\t\tvalue = arr["+
f+"];\n\t\t");var r=b+"["+f+"]",u=this.getRuleFromSchema(d.items[f]);a.push(this.compileRule(u,c,r,"\n\t\t\tarr["+f+"] = "+(c.async?"await ":"")+"context.fn[%%INDEX%%](arr["+f+'], (parentField ? parentField : "") + "[" + '+f+' + "]", parent, errors, context);\n\t\t',"arr["+f+"]"))}a.push("\n\t\treturn arr;\n\t")}else a.push("\n\t\treturn value;\n\t");return{source:a.join("\n")}}function y(a){var b=a.schema;a=a.messages;var c=[],d=!1;!0===b.convert&&(d=!0,c.push('\n\t\t\tif (typeof value !== "string") {\n\t\t\t\tvalue = String(value);\n\t\t\t}\n\t\t'));
c.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar origValue = value;\n\t");b.trim&&(d=!0,c.push("\n\t\t\tvalue = value.trim();\n\t\t"));b.trimLeft&&(d=!0,c.push("\n\t\t\tvalue = value.trimLeft();\n\t\t"));b.trimRight&&(d=!0,c.push("\n\t\t\tvalue = value.trimRight();\n\t\t"));b.padStart&&(d=!0,c.push("\n\t\t\tvalue = value.padStart("+b.padStart+", "+JSON.stringify(null!=b.padChar?b.padChar:" ")+
");\n\t\t"));b.padEnd&&(d=!0,c.push("\n\t\t\tvalue = value.padEnd("+b.padEnd+", "+JSON.stringify(null!=b.padChar?b.padChar:" ")+");\n\t\t"));b.lowercase&&(d=!0,c.push("\n\t\t\tvalue = value.toLowerCase();\n\t\t"));b.uppercase&&(d=!0,c.push("\n\t\t\tvalue = value.toUpperCase();\n\t\t"));b.localeLowercase&&(d=!0,c.push("\n\t\t\tvalue = value.toLocaleLowerCase();\n\t\t"));b.localeUppercase&&(d=!0,c.push("\n\t\t\tvalue = value.toLocaleUpperCase();\n\t\t"));c.push("\n\t\t\tvar len = value.length;\n\t");
!1===b.empty?c.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"stringEmpty",actual:"value",messages:a})+"\n\t\t\t}\n\t\t"):!0===b.empty&&c.push("\n\t\t\tif (len === 0) {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");null!=b.min&&c.push("\n\t\t\tif (len < "+b.min+") {\n\t\t\t\t"+this.makeError({type:"stringMin",expected:b.min,actual:"len",messages:a})+"\n\t\t\t}\n\t\t");null!=b.max&&c.push("\n\t\t\tif (len > "+b.max+") {\n\t\t\t\t"+this.makeError({type:"stringMax",expected:b.max,actual:"len",
messages:a})+"\n\t\t\t}\n\t\t");null!=b.length&&c.push("\n\t\t\tif (len !== "+b.length+") {\n\t\t\t\t"+this.makeError({type:"stringLength",expected:b.length,actual:"len",messages:a})+"\n\t\t\t}\n\t\t");if(null!=b.pattern){var e=b.pattern;"string"==typeof b.pattern&&(e=new RegExp(b.pattern,b.patternFlags));c.push("\n\t\t\tif (!"+e.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringPattern",expected:'"'+e.toString().replace(/"/g,"\\$&")+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t")}null!=
b.contains&&c.push('\n\t\t\tif (value.indexOf("'+b.contains+'") === -1) {\n\t\t\t\t'+this.makeError({type:"stringContains",expected:'"'+b.contains+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");null!=b.enum&&(e=JSON.stringify(b.enum),c.push("\n\t\t\tif ("+e+".indexOf(value) === -1) {\n\t\t\t\t"+this.makeError({type:"stringEnum",expected:'"'+b.enum.join(", ")+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t"));!0===b.numeric&&c.push("\n\t\t\tif (!"+ha.toString()+".test(value) ) {\n\t\t\t\t"+
messages:a})+"\n\t\t\t}\n\t\t");null!=b.length&&c.push("\n\t\t\tif (len !== "+b.length+") {\n\t\t\t\t"+this.makeError({type:"stringLength",expected:b.length,actual:"len",messages:a})+"\n\t\t\t}\n\t\t");if(null!=b.pattern){var f=b.pattern;"string"==typeof b.pattern&&(f=new RegExp(b.pattern,b.patternFlags));c.push("\n\t\t\tif (!"+f.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringPattern",expected:'"'+f.toString().replace(/"/g,"\\$&")+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t")}null!=
b.contains&&c.push('\n\t\t\tif (value.indexOf("'+b.contains+'") === -1) {\n\t\t\t\t'+this.makeError({type:"stringContains",expected:'"'+b.contains+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");null!=b.enum&&(f=JSON.stringify(b.enum),c.push("\n\t\t\tif ("+f+".indexOf(value) === -1) {\n\t\t\t\t"+this.makeError({type:"stringEnum",expected:'"'+b.enum.join(", ")+'"',actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t"));!0===b.numeric&&c.push("\n\t\t\tif (!"+ha.toString()+".test(value) ) {\n\t\t\t\t"+
this.makeError({type:"stringNumeric",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.alpha&&c.push("\n\t\t\tif(!"+ia.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlpha",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.alphanum&&c.push("\n\t\t\tif(!"+ja.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringAlphanum",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.alphadash&&c.push("\n\t\t\tif(!"+ka.toString()+".test(value)) {\n\t\t\t\t"+
this.makeError({type:"stringAlphadash",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.hex&&c.push("\n\t\t\tif(value.length % 2 !== 0 || !"+la.toString()+".test(value)) {\n\t\t\t\t"+this.makeError({type:"stringHex",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.singleLine&&c.push('\n\t\t\tif(value.includes("\\n")) {\n\t\t\t\t'+this.makeError({type:"stringSingleLine",messages:a})+"\n\t\t\t}\n\t\t");!0===b.base64&&c.push("\n\t\t\tif(!"+ma.toString()+".test(value)) {\n\t\t\t\t"+
this.makeError({type:"stringBase64",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function n(a,b,c){var d=a.schema,e=[];e.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"record",actual:"value",messages:a.messages})+"\n\t\t\treturn value;\n\t\t}\n\t");a=d.key||"string";d=d.value||"any";e.push("\n\t\tconst record = value;\n\t\tlet sanitizedKey, sanitizedValue;\n\t\tconst result = {};\n\t\tfor (let key in value) {\n\t");
e.push("sanitizedKey = value = key;");a=this.getRuleFromSchema(a);for(var p in a.messages)p.startsWith("string")&&(a.messages[p]=a.messages[p].replace(" field "," key "));e.push(this.compileRule(a,c,null,"\n\t\tsanitizedKey = "+(c.async?"await ":"")+'context.fn[%%INDEX%%](key, field ? field + "." + key : key, record, errors, context);\n\t',"sanitizedKey"));e.push("sanitizedValue = value = record[key];");p=this.getRuleFromSchema(d);e.push(this.compileRule(p,c,b+"[key]","\n\t\tsanitizedValue = "+(c.async?
"await ":"")+'context.fn[%%INDEX%%](value, field ? field + "." + key : key, record, errors, context);\n\t',"sanitizedValue"));e.push("result[sanitizedKey] = sanitizedValue;");e.push("\n\t\t}\n\t");e.push("return result;");return{source:e.join("\n")}}function k(a,b,c){b=a.schema;var d=a.messages;a=a.index;var e=[];c.customs[a]?c.customs[a].schema=b:c.customs[a]={schema:b};e.push("\n\t\tconst ObjectID = context.customs["+a+"].schema.ObjectID;\n\t\tif (!ObjectID.isValid(value)) {\n\t\t\t"+this.makeError({type:"objectID",
actual:"value",messages:d})+"\n\t\t\treturn;\n\t\t}\n\t");!0===b.convert?e.push("return new ObjectID(value)"):"hexString"===b.convert?e.push("return value.toString()"):e.push("return value");return{source:e.join("\n")}}function q(a,b,c){var d=a.schema;a=a.messages;var e=[];e.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"object",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");var p=d.properties||d.props;if(p){e.push("var parentObj = value;");
e.push("var parentField = field;");for(var v=Object.keys(p),A=0;A<v.length;A++){var z=v[A],D=J(z),P=na.test(D)?"."+D:"['"+D+"']",K="parentObj"+P,Q=(b?b+".":"")+z,E=p[z].label;E=E?"'"+J(E)+"'":void 0;e.push("\n// Field: "+J(Q));e.push('field = parentField ? parentField + "'+P+'" : "'+D+'";');e.push("value = "+K+";");e.push("label = "+E);z=this.getRuleFromSchema(p[z]);e.push(this.compileRule(z,c,Q,"\n\t\t\t\t"+K+" = "+(c.async?"await ":"")+"context.fn[%%INDEX%%](value, field, parentObj, errors, context, label);\n\t\t\t",
K));!0===this.opts.haltOnFirstError&&e.push("if (errors.length) return parentObj;")}d.strict&&(b=Object.keys(p),e.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(b)+".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"===d.strict?(e.push("\n\t\t\t\t\tif (errors.length === 0) {\n\t\t\t\t"),
e.push("\n\t\t\t\t\t\tinvalidProps.forEach(function(field) {\n\t\t\t\t\t\t\tdelete parentObj[field];\n\t\t\t\t\t\t});\n\t\t\t\t"),e.push("\n\t\t\t\t\t}\n\t\t\t\t")):e.push("\n\t\t\t\t\t"+this.makeError({type:"objectStrict",expected:'"'+b.join(", ")+'"',actual:"invalidProps.join(', ')",messages:a})+"\n\t\t\t\t"),e.push("\n\t\t\t\t}\n\t\t\t"))}if(null!=d.minProps||null!=d.maxProps)d.strict?e.push("\n\t\t\t\tprops = Object.keys("+(p?"parentObj":"value")+");\n\t\t\t"):e.push("\n\t\t\t\tvar props = Object.keys("+
(p?"parentObj":"value")+");\n\t\t\t\t"+(p?"field = parentField;":"")+"\n\t\t\t");null!=d.minProps&&e.push("\n\t\t\tif (props.length < "+d.minProps+") {\n\t\t\t\t"+this.makeError({type:"objectMinProps",expected:d.minProps,actual:"props.length",messages:a})+"\n\t\t\t}\n\t\t");null!=d.maxProps&&e.push("\n\t\t\tif (props.length > "+d.maxProps+") {\n\t\t\t\t"+this.makeError({type:"objectMaxProps",expected:d.maxProps,actual:"props.length",messages:a})+"\n\t\t\t}\n\t\t");p?e.push("\n\t\t\treturn parentObj;\n\t\t"):
e.push("\n\t\t\treturn value;\n\t\t");return{source:e.join("\n")}}function u(a){var b=a.schema;a=a.messages;var c=[];c.push("\n\t\tvar origValue = value;\n\t");var d=!1;!0===b.convert&&(d=!0,c.push('\n\t\t\tif (typeof value !== "number") {\n\t\t\t\tvalue = Number(value);\n\t\t\t}\n\t\t'));c.push('\n\t\tif (typeof value !== "number" || isNaN(value) || !isFinite(value)) {\n\t\t\t'+this.makeError({type:"number",actual:"origValue",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");null!=b.min&&c.push("\n\t\t\tif (value < "+
this.makeError({type:"stringBase64",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function n(a,b,c){var d=a.schema,f=[];f.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"record",actual:"value",messages:a.messages})+"\n\t\t\treturn value;\n\t\t}\n\t");a=d.key||"string";d=d.value||"any";f.push("\n\t\tconst record = value;\n\t\tlet sanitizedKey, sanitizedValue;\n\t\tconst result = {};\n\t\tfor (let key in value) {\n\t");
f.push("sanitizedKey = value = key;");a=this.getRuleFromSchema(a);for(var r in a.messages)r.startsWith("string")&&(a.messages[r]=a.messages[r].replace(" field "," key "));f.push(this.compileRule(a,c,null,"\n\t\tsanitizedKey = "+(c.async?"await ":"")+'context.fn[%%INDEX%%](key, field ? field + "." + key : key, record, errors, context);\n\t',"sanitizedKey"));f.push("sanitizedValue = value = record[key];");r=this.getRuleFromSchema(d);f.push(this.compileRule(r,c,b+"[key]","\n\t\tsanitizedValue = "+(c.async?
"await ":"")+'context.fn[%%INDEX%%](value, field ? field + "." + key : key, record, errors, context);\n\t',"sanitizedValue"));f.push("result[sanitizedKey] = sanitizedValue;");f.push("\n\t\t}\n\t");f.push("return result;");return{source:f.join("\n")}}function k(a,b,c){b=a.schema;var d=a.messages;a=a.index;var f=[];c.customs[a]?c.customs[a].schema=b:c.customs[a]={schema:b};f.push("\n\t\tconst ObjectID = context.customs["+a+"].schema.ObjectID;\n\t\tif (!ObjectID.isValid(value)) {\n\t\t\t"+this.makeError({type:"objectID",
actual:"value",messages:d})+"\n\t\t\treturn;\n\t\t}\n\t");!0===b.convert?f.push("return new ObjectID(value)"):"hexString"===b.convert?f.push("return value.toString()"):f.push("return value");return{source:f.join("\n")}}function p(a,b,c){var d=a.schema;a=a.messages;var f=[];f.push('\n\t\tif (typeof value !== "object" || value === null || Array.isArray(value)) {\n\t\t\t'+this.makeError({type:"object",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");var r=d.properties||d.props;if(r){f.push("var parentObj = value;");
f.push("var parentField = field;");for(var u=Object.keys(r),z=0;z<u.length;z++){var A=u[z],D=J(A),P=na.test(D)?"."+D:"['"+D+"']",K="parentObj"+P,Q=(b?b+".":"")+A,E=r[A].label;E=E?"'"+J(E)+"'":void 0;f.push("\n// Field: "+J(Q));f.push('field = parentField ? parentField + "'+P+'" : "'+D+'";');f.push("value = "+K+";");f.push("label = "+E);A=this.getRuleFromSchema(r[A]);f.push(this.compileRule(A,c,Q,"\n\t\t\t\t"+K+" = "+(c.async?"await ":"")+"context.fn[%%INDEX%%](value, field, parentObj, errors, context, label);\n\t\t\t",
K));!0===this.opts.haltOnFirstError&&f.push("if (errors.length) return parentObj;")}d.strict&&(b=Object.keys(r),f.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(b)+".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"===d.strict?(f.push("\n\t\t\t\t\tif (errors.length === 0) {\n\t\t\t\t"),
f.push("\n\t\t\t\t\t\tinvalidProps.forEach(function(field) {\n\t\t\t\t\t\t\tdelete parentObj[field];\n\t\t\t\t\t\t});\n\t\t\t\t"),f.push("\n\t\t\t\t\t}\n\t\t\t\t")):f.push("\n\t\t\t\t\t"+this.makeError({type:"objectStrict",expected:'"'+b.join(", ")+'"',actual:"invalidProps.join(', ')",messages:a})+"\n\t\t\t\t"),f.push("\n\t\t\t\t}\n\t\t\t"))}if(null!=d.minProps||null!=d.maxProps)d.strict?f.push("\n\t\t\t\tprops = Object.keys("+(r?"parentObj":"value")+");\n\t\t\t"):f.push("\n\t\t\t\tvar props = Object.keys("+
(r?"parentObj":"value")+");\n\t\t\t\t"+(r?"field = parentField;":"")+"\n\t\t\t");null!=d.minProps&&f.push("\n\t\t\tif (props.length < "+d.minProps+") {\n\t\t\t\t"+this.makeError({type:"objectMinProps",expected:d.minProps,actual:"props.length",messages:a})+"\n\t\t\t}\n\t\t");null!=d.maxProps&&f.push("\n\t\t\tif (props.length > "+d.maxProps+") {\n\t\t\t\t"+this.makeError({type:"objectMaxProps",expected:d.maxProps,actual:"props.length",messages:a})+"\n\t\t\t}\n\t\t");r?f.push("\n\t\t\treturn parentObj;\n\t\t"):
f.push("\n\t\t\treturn value;\n\t\t");return{source:f.join("\n")}}function v(a){var b=a.schema;a=a.messages;var c=[];c.push("\n\t\tvar origValue = value;\n\t");var d=!1;!0===b.convert&&(d=!0,c.push('\n\t\t\tif (typeof value !== "number") {\n\t\t\t\tvalue = Number(value);\n\t\t\t}\n\t\t'));c.push('\n\t\tif (typeof value !== "number" || isNaN(value) || !isFinite(value)) {\n\t\t\t'+this.makeError({type:"number",actual:"origValue",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");null!=b.min&&c.push("\n\t\t\tif (value < "+
b.min+") {\n\t\t\t\t"+this.makeError({type:"numberMin",expected:b.min,actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");null!=b.max&&c.push("\n\t\t\tif (value > "+b.max+") {\n\t\t\t\t"+this.makeError({type:"numberMax",expected:b.max,actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");null!=b.equal&&c.push("\n\t\t\tif (value !== "+b.equal+") {\n\t\t\t\t"+this.makeError({type:"numberEqual",expected:b.equal,actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");null!=b.notEqual&&c.push("\n\t\t\tif (value === "+
b.notEqual+") {\n\t\t\t\t"+this.makeError({type:"numberNotEqual",expected:b.notEqual,actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.integer&&c.push("\n\t\t\tif (value % 1 !== 0) {\n\t\t\t\t"+this.makeError({type:"numberInteger",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.positive&&c.push("\n\t\t\tif (value <= 0) {\n\t\t\t\t"+this.makeError({type:"numberPositive",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");!0===b.negative&&c.push("\n\t\t\tif (value >= 0) {\n\t\t\t\t"+
this.makeError({type:"numberNegative",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function C(a,b,c){var d=a.schema;a.messages;a=[];a.push("\n\t\tvar hasValid = false;\n\t\tvar newVal = value;\n\t\tvar checkErrors = [];\n\t\tvar errorsSize = errors.length;\n\t");for(var e=0;e<d.rules.length;e++){a.push("\n\t\t\tif (!hasValid) {\n\t\t\t\tvar _errors = [];\n\t\t");var p=this.getRuleFromSchema(d.rules[e]);a.push(this.compileRule(p,
this.makeError({type:"numberNegative",actual:"origValue",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function C(a,b,c){var d=a.schema;a.messages;a=[];a.push("\n\t\tvar hasValid = false;\n\t\tvar newVal = value;\n\t\tvar checkErrors = [];\n\t\tvar errorsSize = errors.length;\n\t");for(var f=0;f<d.rules.length;f++){a.push("\n\t\t\tif (!hasValid) {\n\t\t\t\tvar _errors = [];\n\t\t");var r=this.getRuleFromSchema(d.rules[f]);a.push(this.compileRule(r,
c,b,"var tmpVal = "+(c.async?"await ":"")+"context.fn[%%INDEX%%](value, field, parent, _errors, context);","tmpVal"));a.push("\n\t\t\t\tif (errors.length == errorsSize && _errors.length == 0) {\n\t\t\t\t\thasValid = true;\n\t\t\t\t\tnewVal = tmpVal;\n\t\t\t\t} else {\n\t\t\t\t\tArray.prototype.push.apply(checkErrors, [].concat(_errors, errors.splice(errorsSize)));\n\t\t\t\t}\n\t\t\t}\n\t\t")}a.push("\n\t\tif (!hasValid) {\n\t\t\tArray.prototype.push.apply(errors, checkErrors);\n\t\t}\n\n\t\treturn newVal;\n\t");

@@ -58,15 +58,15 @@ return{source:a.join("\n")}}function ca(a){a.schema;return{source:'\n\t\t\tif (typeof value !== "function")\n\t\t\t\t'+this.makeError({type:"function",actual:"value",messages:a.messages})+"\n\n\t\t\treturn value;\n\t\t"}}function ba(a){var b=a.schema;a=a.messages;var c=[];c.push("\n\t\tif (value !== null && value !== undefined) {\n\t");b.remove?c.push("\n\t\t\treturn undefined;\n\t\t"):c.push("\n\t\t\t"+this.makeError({type:"forbidden",actual:"value",messages:a})+"\n\t\t");c.push("\n\t\t}\n\n\t\treturn value;\n\t");

c.push("\n\t\t\t\t"+this.makeError({type:"equalValue",actual:"value",expected:JSON.stringify(b.value),messages:a})+"\n\t\t"));c.push("\n\t\treturn value;\n\t");return{source:c.join("\n")}}function Z(a){var b=a.schema;a=a.messages;return{source:"\n\t\t\tif ("+JSON.stringify(b.values||[])+".indexOf(value) === -1)\n\t\t\t\t"+this.makeError({type:"enumValue",expected:'"'+b.values.join(", ")+'"',actual:"value",messages:a})+"\n\t\t\t\n\t\t\treturn value;\n\t\t"}}function Y(a){var b=a.schema;a=a.messages;
var c=[],d="precise"==b.mode?oa:pa,e=!1;c.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");b.empty?c.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):c.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\t"+this.makeError({type:"emailEmpty",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");b.normalize&&(e=!0,c.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t"));null!=
b.min&&c.push("\n\t\t\tif (value.length < "+b.min+") {\n\t\t\t\t"+this.makeError({type:"emailMin",expected:b.min,actual:"value.length",messages:a})+"\n\t\t\t}\n\t\t");null!=b.max&&c.push("\n\t\t\tif (value.length > "+b.max+") {\n\t\t\t\t"+this.makeError({type:"emailMax",expected:b.max,actual:"value.length",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\tif (!"+d.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"email",actual:"value",messages:a})+"\n\t\t}\n\n\t\treturn value;\n\t");return{sanitized:e,
var c=[],d="precise"==b.mode?oa:pa,f=!1;c.push('\n\t\tif (typeof value !== "string") {\n\t\t\t'+this.makeError({type:"string",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\t");b.empty?c.push("\n\t\t\tif (value.length === 0) return value;\n\t\t"):c.push("\n\t\t\tif (value.length === 0) {\n\t\t\t\t"+this.makeError({type:"emailEmpty",actual:"value",messages:a})+"\n\t\t\t\treturn value;\n\t\t\t}\n\t\t");b.normalize&&(f=!0,c.push("\n\t\t\tvalue = value.trim().toLowerCase();\n\t\t"));null!=
b.min&&c.push("\n\t\t\tif (value.length < "+b.min+") {\n\t\t\t\t"+this.makeError({type:"emailMin",expected:b.min,actual:"value.length",messages:a})+"\n\t\t\t}\n\t\t");null!=b.max&&c.push("\n\t\t\tif (value.length > "+b.max+") {\n\t\t\t\t"+this.makeError({type:"emailMax",expected:b.max,actual:"value.length",messages:a})+"\n\t\t\t}\n\t\t");c.push("\n\t\tif (!"+d.toString()+".test(value)) {\n\t\t\t"+this.makeError({type:"email",actual:"value",messages:a})+"\n\t\t}\n\n\t\treturn value;\n\t");return{sanitized:f,
source:c.join("\n")}}function X(a){var b=a.schema;a=a.messages;var c=[],d=!1;c.push("\n\t\tvar origValue = value;\n\t");!0===b.convert&&(d=!0,c.push("\n\t\t\tif (!(value instanceof Date)) {\n\t\t\t\tvalue = new Date(value.length && !isNaN(+value) ? +value : value);\n\t\t\t}\n\t\t"));c.push("\n\t\tif (!(value instanceof Date) || isNaN(value.getTime()))\n\t\t\t"+this.makeError({type:"date",actual:"origValue",messages:a})+"\n\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function W(a){var b=
a.schema;a=a.messages;var c=b.currencySymbol||null,d=b.thousandSeparator||",",e=b.decimalSeparator||".",p=b.customRegex;b=!b.symbolOptional;b="(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$".replace(/~1/g,c?"\\"+c+(b?"":"?"):"").replace("~2",d).replace("~3",e);c=[];c.push("\n\t\tif (!value.match("+(p||new RegExp(b))+")) {\n\t\t\t"+this.makeError({type:"currency",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\n\t\treturn value;\n\t");return{source:c.join("\n")}}function V(a,
b,c){var d=[];d.push("\n\t\t"+this.makeCustomValidator({fnName:"check",path:b,schema:a.schema,messages:a.messages,context:c,ruleIndex:a.index})+"\n\t\treturn value;\n\t");return{source:d.join("\n")}}function U(a,b,c){b=a.schema;var d=a.messages;a=a.index;var e=[],p=b.instanceOf.name?b.instanceOf.name:"<UnknowClass>";c.customs[a]?c.customs[a].schema=b:c.customs[a]={schema:b};e.push("\n\t\tif (!(value instanceof context.customs["+a+"].schema.instanceOf))\n\t\t\t"+this.makeError({type:"classInstanceOf",
actual:"value",expected:"'"+p+"'",messages:d})+"\n\t");e.push("\n\t\treturn value;\n\t");return{source:e.join("\n")}}function T(a){var b=a.schema;a=a.messages;var c=[],d=!1;c.push("\n\t\tvar origValue = value;\n\t");!0===b.convert&&(d=!0,c.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'));
c.push('\n\t\tif (typeof value !== "boolean") {\n\t\t\t'+this.makeError({type:"boolean",actual:"origValue",messages:a})+"\n\t\t}\n\t\t\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function S(a,b,c){var d=a.schema,e=a.messages;a=[];var p=!1;!0===d.convert&&(p=!0,a.push("\n\t\t\tif (!Array.isArray(value) && value != null) {\n\t\t\t\tvalue = [value];\n\t\t\t}\n\t\t"));a.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"array",actual:"value",messages:e})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t");
!1===d.empty&&a.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"arrayEmpty",actual:"value",messages:e})+"\n\t\t\t}\n\t\t");null!=d.min&&a.push("\n\t\t\tif (len < "+d.min+") {\n\t\t\t\t"+this.makeError({type:"arrayMin",expected:d.min,actual:"len",messages:e})+"\n\t\t\t}\n\t\t");null!=d.max&&a.push("\n\t\t\tif (len > "+d.max+") {\n\t\t\t\t"+this.makeError({type:"arrayMax",expected:d.max,actual:"len",messages:e})+"\n\t\t\t}\n\t\t");null!=d.length&&a.push("\n\t\t\tif (len !== "+d.length+
") {\n\t\t\t\t"+this.makeError({type:"arrayLength",expected:d.length,actual:"len",messages:e})+"\n\t\t\t}\n\t\t");null!=d.contains&&a.push("\n\t\t\tif (value.indexOf("+JSON.stringify(d.contains)+") === -1) {\n\t\t\t\t"+this.makeError({type:"arrayContains",expected:JSON.stringify(d.contains),actual:"value",messages:e})+"\n\t\t\t}\n\t\t");!0===d.unique&&a.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:e})+"\n\t\t\t}\n\t\t");if(null!=d.enum){var v=JSON.stringify(d.enum);a.push("\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tif ("+v+".indexOf(value[i]) === -1) {\n\t\t\t\t\t"+this.makeError({type:"arrayEnum",expected:'"'+d.enum.join(", ")+'"',actual:"value[i]",messages:e})+"\n\t\t\t\t}\n\t\t\t}\n\t\t")}null!=d.items?(a.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\t\tvalue = arr[i];\n\t\t"),b+=
"[]",d=this.getRuleFromSchema(d.items),a.push(this.compileRule(d,c,b,"arr[i] = "+(c.async?"await ":"")+'context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context)',"arr[i]")),a.push("\n\t\t\t}\n\t\t"),a.push("\n\t\treturn arr;\n\t")):a.push("\n\t\treturn value;\n\t");return{sanitized:p,source:a.join("\n")}}function R(){var a=[];a.push("\n\t\treturn value;\n\t");return{source:a.join("\n")}}function qa(a,b,c){return a.replace(b,void 0===c||null===c?"":"function"===
typeof c.toString?c:typeof c)}function B(a,b,c){void 0===c&&(c={});for(var d in b){var e=b[d];e="object"!==typeof e||Array.isArray(e)||null==e?!1:0<Object.keys(e).length;if(e)a[d]=a[d]||{},B(a[d],b[d],c);else if(!0!==c.skipIfExist||void 0===a[d])a[d]=b[d]}return a}function J(a){return a.replace(ra,function(b){switch(b){case '"':case "'":case "\\":return"\\"+b;case "\n":return"\\n";case "\r":return"\\r";case "\u2028":return"\\u2028";case "\u2029":return"\\u2029"}})}function M(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs");
}var r={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.",
a.schema;a=a.messages;var c=b.currencySymbol||null,d=b.thousandSeparator||",",f=b.decimalSeparator||".",r=b.customRegex;b=!b.symbolOptional;b="(?=.*\\d)^(-?~1|~1-?)(([0-9]\\d{0,2}(~2\\d{3})*)|0)?(\\~3\\d{1,2})?$".replace(/~1/g,c?"\\"+c+(b?"":"?"):"").replace("~2",d).replace("~3",f);c=[];c.push("\n\t\tif (!value.match("+(r||new RegExp(b))+")) {\n\t\t\t"+this.makeError({type:"currency",actual:"value",messages:a})+"\n\t\t\treturn value;\n\t\t}\n\n\t\treturn value;\n\t");return{source:c.join("\n")}}function V(a,
b,c){var d=[];d.push("\n\t\t"+this.makeCustomValidator({fnName:"check",path:b,schema:a.schema,messages:a.messages,context:c,ruleIndex:a.index})+"\n\t\treturn value;\n\t");return{source:d.join("\n")}}function U(a,b,c){b=a.schema;var d=a.messages;a=a.index;var f=[],r=b.instanceOf.name?b.instanceOf.name:"<UnknowClass>";c.customs[a]?c.customs[a].schema=b:c.customs[a]={schema:b};f.push("\n\t\tif (!(value instanceof context.customs["+a+"].schema.instanceOf))\n\t\t\t"+this.makeError({type:"classInstanceOf",
actual:"value",expected:"'"+r+"'",messages:d})+"\n\t");f.push("\n\t\treturn value;\n\t");return{source:f.join("\n")}}function T(a){var b=a.schema;a=a.messages;var c=[],d=!1;c.push("\n\t\tvar origValue = value;\n\t");!0===b.convert&&(d=!0,c.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'));
c.push('\n\t\tif (typeof value !== "boolean") {\n\t\t\t'+this.makeError({type:"boolean",actual:"origValue",messages:a})+"\n\t\t}\n\t\t\n\t\treturn value;\n\t");return{sanitized:d,source:c.join("\n")}}function S(a,b,c){var d=a.schema,f=a.messages;a=[];var r=!1;!0===d.convert&&(r=!0,a.push("\n\t\t\tif (!Array.isArray(value) && value != null) {\n\t\t\t\tvalue = [value];\n\t\t\t}\n\t\t"));a.push("\n\t\tif (!Array.isArray(value)) {\n\t\t\t"+this.makeError({type:"array",actual:"value",messages:f})+"\n\t\t\treturn value;\n\t\t}\n\n\t\tvar len = value.length;\n\t");
!1===d.empty&&a.push("\n\t\t\tif (len === 0) {\n\t\t\t\t"+this.makeError({type:"arrayEmpty",actual:"value",messages:f})+"\n\t\t\t}\n\t\t");null!=d.min&&a.push("\n\t\t\tif (len < "+d.min+") {\n\t\t\t\t"+this.makeError({type:"arrayMin",expected:d.min,actual:"len",messages:f})+"\n\t\t\t}\n\t\t");null!=d.max&&a.push("\n\t\t\tif (len > "+d.max+") {\n\t\t\t\t"+this.makeError({type:"arrayMax",expected:d.max,actual:"len",messages:f})+"\n\t\t\t}\n\t\t");null!=d.length&&a.push("\n\t\t\tif (len !== "+d.length+
") {\n\t\t\t\t"+this.makeError({type:"arrayLength",expected:d.length,actual:"len",messages:f})+"\n\t\t\t}\n\t\t");null!=d.contains&&a.push("\n\t\t\tif (value.indexOf("+JSON.stringify(d.contains)+") === -1) {\n\t\t\t\t"+this.makeError({type:"arrayContains",expected:JSON.stringify(d.contains),actual:"value",messages:f})+"\n\t\t\t}\n\t\t");!0===d.unique&&a.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:f})+"\n\t\t\t}\n\t\t");if(null!=d.enum){var u=JSON.stringify(d.enum);a.push("\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tif ("+u+".indexOf(value[i]) === -1) {\n\t\t\t\t\t"+this.makeError({type:"arrayEnum",expected:'"'+d.enum.join(", ")+'"',actual:"value[i]",messages:f})+"\n\t\t\t\t}\n\t\t\t}\n\t\t")}null!=d.items?(a.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\t\tvalue = arr[i];\n\t\t"),b+=
"[]",d=this.getRuleFromSchema(d.items),a.push(this.compileRule(d,c,b,"arr[i] = "+(c.async?"await ":"")+'context.fn[%%INDEX%%](arr[i], (parentField ? parentField : "") + "[" + i + "]", parent, errors, context)',"arr[i]")),a.push("\n\t\t\t}\n\t\t"),a.push("\n\t\treturn arr;\n\t")):a.push("\n\t\treturn value;\n\t");return{sanitized:r,source:a.join("\n")}}function R(){var a=[];a.push("\n\t\treturn value;\n\t");return{source:a.join("\n")}}function qa(a,b,c){return a.replace(b,void 0===c||null===c?"":"function"===
typeof c.toString?c:typeof c)}function B(a,b,c){void 0===c&&(c={});for(var d in b){var f=b[d];f="object"!==typeof f||Array.isArray(f)||null==f?!1:0<Object.keys(f).length;if(f)a[d]=a[d]||{},B(a[d],b[d],c);else if(!0!==c.skipIfExist||void 0===a[d])a[d]=b[d]}return a}function J(a){return a.replace(ra,function(b){switch(b){case '"':case "'":case "\\":return"\\"+b;case "\n":return"\\n";case "\r":return"\\r";case "\u2028":return"\\u2028";case "\u2029":return"\\u2029"}})}function M(){throw Error("Dynamic requires are not currently supported by rollup-plugin-commonjs");
}var q={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.",

@@ -78,19 +78,20 @@ 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.",

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",record:"The '{field}' must be an Object."};r.required;r.string;r.stringEmpty;r.stringMin;r.stringMax;r.stringLength;r.stringPattern;r.stringContains;r.stringEnum;r.stringNumeric;r.stringAlpha;r.stringAlphanum;r.stringAlphadash;r.stringHex;r.stringSingleLine;r.stringBase64;r.number;r.numberMin;
r.numberMax;r.numberEqual;r.numberNotEqual;r.numberInteger;r.numberPositive;r.numberNegative;r.array;r.arrayEmpty;r.arrayMin;r.arrayMax;r.arrayLength;r.arrayContains;r.arrayUnique;r.arrayEnum;r.tuple;r.tupleEmpty;r.tupleLength;r.currency;r.date;r.dateMin;r.dateMax;r.enumValue;r.equalValue;r.equalField;r.forbidden;r.email;r.emailEmpty;r.emailMin;r.emailMax;r.luhn;r.mac;r.object;r.objectStrict;r.objectMinProps;r.objectMaxProps;r.url;r.urlEmpty;r.uuid;r.uuidVersion;r.classInstanceOf;r.objectID;r.record;
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",record:"The '{field}' must be an Object."};q.required;q.string;q.stringEmpty;q.stringMin;q.stringMax;q.stringLength;q.stringPattern;q.stringContains;q.stringEnum;q.stringNumeric;q.stringAlpha;q.stringAlphanum;q.stringAlphadash;q.stringHex;q.stringSingleLine;q.stringBase64;q.number;q.numberMin;
q.numberMax;q.numberEqual;q.numberNotEqual;q.numberInteger;q.numberPositive;q.numberNegative;q.array;q.arrayEmpty;q.arrayMin;q.arrayMax;q.arrayLength;q.arrayContains;q.arrayUnique;q.arrayEnum;q.tuple;q.tupleEmpty;q.tupleLength;q.currency;q.date;q.dateMin;q.dateMax;q.enumValue;q.equalValue;q.equalField;q.forbidden;q.email;q.emailEmpty;q.emailMin;q.emailMax;q.luhn;q.mac;q.object;q.objectStrict;q.objectMinProps;q.objectMaxProps;q.url;q.urlEmpty;q.uuid;q.uuidVersion;q.classInstanceOf;q.objectID;q.record;
var oa=/^(([^<>()[\]\\.,;:\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,}))$/,pa=/^\S+@\S+\.\S+$/,na=/^[_$a-zA-Z][_$a-zA-Z0-9]*$/,ra=/["'\\\n\r\u2028\u2029]/g,ha=/^-?[0-9]\d*(\.\d+)?$/,ia=/^[a-zA-Z]+$/,ja=/^[a-zA-Z0-9]+$/,ka=/^[a-zA-Z0-9_-]+$/,la=/^[0-9a-fA-F]+$/,ma=/^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+/]{3}=)?$/,fa=/^https?:\/\/\S+/,ea=/^([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,
da=/^((([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,H,N,I,O;try{var L=(new Function("return Object.getPrototypeOf(async function(){}).constructor"))()}catch(a){}f.prototype.validate=function(a,b){return this.compile(b)(a)};f.prototype.wrapRequiredCheckSourceCode=function(a,b,c,d){var e=[],p=!0===a.schema.optional||"forbidden"===a.schema.type,v=!0===a.schema.optional||!0===a.schema.nullable||
"forbidden"===a.schema.type;null!=a.schema.default?(p=!1,!0!==a.schema.nullable&&(v=!1),"function"===typeof a.schema.default?(c.customs[a.index]||(c.customs[a.index]={}),c.customs[a.index].defaultFn=a.schema.default,a="context.customs["+a.index+"].defaultFn.call(this, context.rules["+a.index+"].schema, field, parent, context)"):a=JSON.stringify(a.schema.default),d="\n\t\t\t\tvalue = "+a+";\n\t\t\t\t"+d+" = value;\n\t\t\t"):d=this.makeError({type:"required",actual:"value",messages:a.messages});e.push("\n\t\t\tif (value === undefined) { "+
((p?"\n// allow undefined\n":d)+" }\n\t\t\telse if (value === null) { ")+((v?"\n// allow null\n":d)+" }\n\t\t\t")+(b?"else { "+b+" }":"")+"\n\t\t");return e.join("\n")};f.prototype.compile=function(a){function b(v,A){d.data=v;A&&A.meta&&(d.meta=A.meta);return p.call(c,v,d)}if(null===a||"object"!==typeof a)throw Error("Invalid schema.");var c=this,d={index:0,async:!0===a.$$async,rules:[],fn:[],customs:{},utils:{replace:qa}};this.cache.clear();delete a.$$async;if(d.async&&!L)throw Error("Asynchronous mode is not supported.");
if(!0!==a.$$root)if(Array.isArray(a))a=this.getRuleFromSchema(a).schema;else{var e=Object.assign({},a);a={type:"object",strict:e.$$strict,properties:e};delete e.$$strict}e=["var errors = [];","var field;","var parent = null;","var label = "+(a.label?'"'+a.label+'"':"null")+";"];a=this.getRuleFromSchema(a);e.push(this.compileRule(a,d,null,(d.async?"await ":"")+"context.fn[%%INDEX%%](value, field, null, errors, context, label);","value"));e.push("if (errors.length) {");e.push("\n\t\t\treturn errors.map(err => {\n\t\t\t\tif (err.message) {\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{field\\}/g, err.label || err.field);\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{expected\\}/g, err.expected);\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{actual\\}/g, err.actual);\n\t\t\t\t}\n\t\t\t\tif(!err.label) delete err.label\n\t\t\t\treturn err;\n\t\t\t});\n\t\t");
e.push("}");e.push("return true;");a=e.join("\n");var p=new (d.async?L:Function)("value","context",a);this.opts.debug&&console.log(this._formatter("// Main check function\n"+p.toString()));this.cache.clear();b.async=d.async;return b};f.prototype.compileRule=function(a,b,c,d,e){var p=[],v=this.cache.get(a.schema);v?(a=v,a.cycle=!0,a.cycleStack=[],p.push(this.wrapRequiredCheckSourceCode(a,"\n\t\t\t\tvar rule = context.rules["+a.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"+
d.replace(/%%INDEX%%/g,a.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",b,e))):(this.cache.set(a.schema,a),a.index=b.index,b.rules[b.index]=a,v=null!=c?c:"$$root",b.index++,c=a.ruleFunction.call(this,a,c,b),c.source=c.source.replace(/%%INDEX%%/g,a.index),c=new (b.async?L:Function)("value","field","parent","errors","context","label",c.source),b.fn[a.index]=c.bind(this),p.push(this.wrapRequiredCheckSourceCode(a,d.replace(/%%INDEX%%/g,a.index),b,e)),p.push(this.makeCustomValidator({vName:e,
path:v,schema:a.schema,context:b,messages:a.messages,ruleIndex:a.index})),this.opts.debug&&console.log(this._formatter("// Context.fn["+a.index+"]\n"+c.toString())));return p.join("\n")};f.prototype.getRuleFromSchema=function(a){a=this.resolveType(a);var b=this.aliases[a.type];b&&(delete a.type,a=B(a,b,{skipIfExist:!0}));b=this.rules[a.type];if(!b)throw Error("Invalid '"+a.type+"' type in validator schema.");return{messages:Object.assign({},this.messages,a.messages),schema:B(a,this.defaults[a.type],
{skipIfExist:!0}),ruleFunction:b}};f.prototype.parseShortHand=function(a){a=a.split("|").map(function(d){return d.trim()});var b=a[0];var c=b.endsWith("[]")?this.getRuleFromSchema({type:"array",items:b.slice(0,-2)}).schema:{type:a[0]};a.slice(1).map(function(d){var e=d.indexOf(":");if(-1!==e){var p=d.substr(0,e).trim();d=d.substr(e+1).trim();"true"===d||"false"===d?d="true"===d:Number.isNaN(Number(d))||(d=Number(d));c[p]=d}else d.startsWith("no-")?c[d.slice(3)]=!1:c[d]=!0});return c};f.prototype.makeError=
function(a){var b=a.type,c=a.field,d=a.expected,e=a.actual,p={type:'"'+b+'"',message:'"'+a.messages[b]+'"'};p.field=c?'"'+c+'"':"field";null!=d&&(p.expected=d);null!=e&&(p.actual=e);p.label="label";return"errors.push({ "+Object.keys(p).map(function(v){return v+": "+p[v]}).join(", ")+" });"};f.prototype.makeCustomValidator=function(a){var b=a.vName;void 0===b&&(b="value");var c=a.fnName;void 0===c&&(c="custom");var d=a.ruleIndex,e=a.path,p=a.schema,v=a.context,A=a.messages;a="rule"+d;var z="fnCustomErrors"+
d;if("function"==typeof p[c]){v.customs[d]?(v.customs[d].messages=A,v.customs[d].schema=p):v.customs[d]={messages:A,schema:p};if(this.opts.useNewCustomCheckerFunction)return"\n \t\tconst "+a+" = context.customs["+d+"];\n\t\t\t\t\tconst "+z+" = [];\n\t\t\t\t\t"+b+" = "+(v.async?"await ":"")+a+".schema."+c+".call(this, "+b+", "+z+" , "+a+'.schema, "'+e+'", parent, context);\n\t\t\t\t\tif (Array.isArray('+z+" )) {\n \t\t"+z+" .forEach(err => errors.push(Object.assign({ message: "+
a+".messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t";p="res_"+a;return"\n\t\t\t\tconst "+a+" = context.customs["+d+"];\n\t\t\t\tconst "+p+" = "+(v.async?"await ":"")+a+".schema."+c+".call(this, "+b+", "+a+'.schema, "'+e+'", parent, context);\n\t\t\t\tif (Array.isArray('+p+")) {\n\t\t\t\t\t"+p+".forEach(err => errors.push(Object.assign({ message: "+a+".messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t"}return""};f.prototype.add=function(a,b){this.rules[a]=b};f.prototype.addMessage=
function(a,b){this.messages[a]=b};f.prototype.alias=function(a,b){if(this.rules[a])throw Error("Alias name must not be a rule name");this.aliases[a]=b};f.prototype.plugin=function(a){if("function"!==typeof a)throw Error("Plugin fn type must be function");return a(this)};f.prototype.resolveType=function(a){var b=this;if("string"===typeof a)a=this.parseShortHand(a);else if(Array.isArray(a)){if(0===a.length)throw Error("Invalid schema.");a={type:"multi",rules:a};a.rules.map(function(p){return b.getRuleFromSchema(p)}).every(function(p){return!0===
p.schema.optional})&&(a.optional=!0);a.rules.map(function(p){return b.getRuleFromSchema(p)}).every(function(p){return!0===p.schema.nullable})&&(a.nullable=!0)}if(a.$$type){var c=this.getRuleFromSchema(a.$$type).schema;delete a.$$type;var d=Object.assign({},a),e;for(e in a)delete a[e];B(a,c,{skipIfExist:!0});a.props=d}return a};f.prototype.normalize=function(a){var b=this,c=this.resolveType(a);this.aliases[c.type]&&(c=B(c,this.normalize(this.aliases[c.type]),{skipIfExists:!0}));c=B(c,this.defaults[c.type],
{skipIfExist:!0});if("multi"===c.type)return c.rules=c.rules.map(function(d){return b.normalize(d)}),c.optional=c.rules.every(function(d){return!0===d.optional}),c;if("array"===c.type)return c.items=this.normalize(c.items),c;"object"===c.type&&c.props&&Object.entries(c.props).forEach(function(d){return c.props[d[0]]=b.normalize(d[1])});"object"===typeof a&&(a.type?(a=this.normalize(a.type),B(c,a,{skipIfExists:!0})):Object.entries(a).forEach(function(d){return c[d[0]]=b.normalize(d[1])}));return c};
return f}"object"===typeof exports&&"undefined"!==typeof module?module.exports=G():"function"===typeof define&&define.amd?define(G):(F="undefined"!==typeof globalThis?globalThis:F||self,F.FastestValidator=G())
da=/^((([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,H,N,I,O;try{var L=(new Function("return Object.getPrototypeOf(async function(){}).constructor"))()}catch(a){}e.prototype.validate=function(a,b){return this.compile(b)(a)};e.prototype.wrapRequiredCheckSourceCode=function(a,b,c,d){var f=[],r=this.opts.considerNullAsAValue;void 0===r&&(r=!1);var u=!0===a.schema.optional||"forbidden"===a.schema.type,
z=r?!1!==a.schema.nullable||"forbidden"===a.schema.type:!0===a.schema.optional||!0===a.schema.nullable||"forbidden"===a.schema.type;(r?void 0!=a.schema.default&&null!=a.schema.default:void 0!=a.schema.default)?(u=!1,r?!1===a.schema.nullable&&(z=!1):!0!==a.schema.nullable&&(z=!1),"function"===typeof a.schema.default?(c.customs[a.index]||(c.customs[a.index]={}),c.customs[a.index].defaultFn=a.schema.default,a="context.customs["+a.index+"].defaultFn.call(this, context.rules["+a.index+"].schema, field, parent, context)"):
a=JSON.stringify(a.schema.default),d="\n\t\t\t\tvalue = "+a+";\n\t\t\t\t"+d+" = value;\n\t\t\t"):d=this.makeError({type:"required",actual:"value",messages:a.messages});f.push("\n\t\t\tif (value === undefined) { "+((u?"\n// allow undefined\n":d)+" }\n\t\t\telse if (value === null) { ")+((z?"\n// allow null\n":d)+" }\n\t\t\t")+(b?"else { "+b+" }":"")+"\n\t\t");return f.join("\n")};e.prototype.compile=function(a){function b(u,z){d.data=u;z&&z.meta&&(d.meta=z.meta);return r.call(c,u,d)}if(null===a||"object"!==
typeof a)throw Error("Invalid schema.");var c=this,d={index:0,async:!0===a.$$async,rules:[],fn:[],customs:{},utils:{replace:qa}};this.cache.clear();delete a.$$async;if(d.async&&!L)throw Error("Asynchronous mode is not supported.");if(!0!==a.$$root)if(Array.isArray(a))a=this.getRuleFromSchema(a).schema;else{var f=Object.assign({},a);a={type:"object",strict:f.$$strict,properties:f};delete f.$$strict}f=["var errors = [];","var field;","var parent = null;","var label = "+(a.label?'"'+a.label+'"':"null")+
";"];a=this.getRuleFromSchema(a);f.push(this.compileRule(a,d,null,(d.async?"await ":"")+"context.fn[%%INDEX%%](value, field, null, errors, context, label);","value"));f.push("if (errors.length) {");f.push("\n\t\t\treturn errors.map(err => {\n\t\t\t\tif (err.message) {\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{field\\}/g, err.label || err.field);\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{expected\\}/g, err.expected);\n\t\t\t\t\terr.message = context.utils.replace(err.message, /\\{actual\\}/g, err.actual);\n\t\t\t\t}\n\t\t\t\tif(!err.label) delete err.label\n\t\t\t\treturn err;\n\t\t\t});\n\t\t");
f.push("}");f.push("return true;");a=f.join("\n");var r=new (d.async?L:Function)("value","context",a);this.opts.debug&&console.log(this._formatter("// Main check function\n"+r.toString()));this.cache.clear();b.async=d.async;return b};e.prototype.compileRule=function(a,b,c,d,f){var r=[],u=this.cache.get(a.schema);u?(a=u,a.cycle=!0,a.cycleStack=[],r.push(this.wrapRequiredCheckSourceCode(a,"\n\t\t\t\tvar rule = context.rules["+a.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"+
d.replace(/%%INDEX%%/g,a.index)+"\n\t\t\t\t\trule.cycleStack.pop(value);\n\t\t\t\t}\n\t\t\t",b,f))):(this.cache.set(a.schema,a),a.index=b.index,b.rules[b.index]=a,u=null!=c?c:"$$root",b.index++,c=a.ruleFunction.call(this,a,c,b),c.source=c.source.replace(/%%INDEX%%/g,a.index),c=new (b.async?L:Function)("value","field","parent","errors","context","label",c.source),b.fn[a.index]=c.bind(this),r.push(this.wrapRequiredCheckSourceCode(a,d.replace(/%%INDEX%%/g,a.index),b,f)),r.push(this.makeCustomValidator({vName:f,
path:u,schema:a.schema,context:b,messages:a.messages,ruleIndex:a.index})),this.opts.debug&&console.log(this._formatter("// Context.fn["+a.index+"]\n"+c.toString())));return r.join("\n")};e.prototype.getRuleFromSchema=function(a){a=this.resolveType(a);var b=this.aliases[a.type];b&&(delete a.type,a=B(a,b,{skipIfExist:!0}));b=this.rules[a.type];if(!b)throw Error("Invalid '"+a.type+"' type in validator schema.");return{messages:Object.assign({},this.messages,a.messages),schema:B(a,this.defaults[a.type],
{skipIfExist:!0}),ruleFunction:b}};e.prototype.parseShortHand=function(a){a=a.split("|").map(function(d){return d.trim()});var b=a[0];var c=b.endsWith("[]")?this.getRuleFromSchema({type:"array",items:b.slice(0,-2)}).schema:{type:a[0]};a.slice(1).map(function(d){var f=d.indexOf(":");if(-1!==f){var r=d.substr(0,f).trim();d=d.substr(f+1).trim();"true"===d||"false"===d?d="true"===d:Number.isNaN(Number(d))||(d=Number(d));c[r]=d}else d.startsWith("no-")?c[d.slice(3)]=!1:c[d]=!0});return c};e.prototype.makeError=
function(a){var b=a.type,c=a.field,d=a.expected,f=a.actual,r={type:'"'+b+'"',message:'"'+a.messages[b]+'"'};r.field=c?'"'+c+'"':"field";null!=d&&(r.expected=d);null!=f&&(r.actual=f);r.label="label";return"errors.push({ "+Object.keys(r).map(function(u){return u+": "+r[u]}).join(", ")+" });"};e.prototype.makeCustomValidator=function(a){var b=a.vName;void 0===b&&(b="value");var c=a.fnName;void 0===c&&(c="custom");var d=a.ruleIndex,f=a.path,r=a.schema,u=a.context,z=a.messages;a="rule"+d;var A="fnCustomErrors"+
d;if("function"==typeof r[c]){u.customs[d]?(u.customs[d].messages=z,u.customs[d].schema=r):u.customs[d]={messages:z,schema:r};if(this.opts.useNewCustomCheckerFunction)return"\n \t\tconst "+a+" = context.customs["+d+"];\n\t\t\t\t\tconst "+A+" = [];\n\t\t\t\t\t"+b+" = "+(u.async?"await ":"")+a+".schema."+c+".call(this, "+b+", "+A+" , "+a+'.schema, "'+f+'", parent, context);\n\t\t\t\t\tif (Array.isArray('+A+" )) {\n \t\t"+A+" .forEach(err => errors.push(Object.assign({ message: "+
a+".messages[err.type], field }, err)));\n\t\t\t\t\t}\n\t\t\t\t";r="res_"+a;return"\n\t\t\t\tconst "+a+" = context.customs["+d+"];\n\t\t\t\tconst "+r+" = "+(u.async?"await ":"")+a+".schema."+c+".call(this, "+b+", "+a+'.schema, "'+f+'", parent, context);\n\t\t\t\tif (Array.isArray('+r+")) {\n\t\t\t\t\t"+r+".forEach(err => errors.push(Object.assign({ message: "+a+".messages[err.type], field }, err)));\n\t\t\t\t}\n\t\t"}return""};e.prototype.add=function(a,b){this.rules[a]=b};e.prototype.addMessage=
function(a,b){this.messages[a]=b};e.prototype.alias=function(a,b){if(this.rules[a])throw Error("Alias name must not be a rule name");this.aliases[a]=b};e.prototype.plugin=function(a){if("function"!==typeof a)throw Error("Plugin fn type must be function");return a(this)};e.prototype.resolveType=function(a){var b=this;if("string"===typeof a)a=this.parseShortHand(a);else if(Array.isArray(a)){if(0===a.length)throw Error("Invalid schema.");a={type:"multi",rules:a};a.rules.map(function(u){return b.getRuleFromSchema(u)}).every(function(u){return!0===
u.schema.optional})&&(a.optional=!0);var c=this.opts.considerNullAsAValue?!1:!0;a.rules.map(function(u){return b.getRuleFromSchema(u)}).every(function(u){return u.schema.nullable===c})&&(a.nullable=c)}if(a.$$type){var d=this.getRuleFromSchema(a.$$type).schema;delete a.$$type;var f=Object.assign({},a),r;for(r in a)delete a[r];B(a,d,{skipIfExist:!0});a.props=f}return a};e.prototype.normalize=function(a){var b=this,c=this.resolveType(a);this.aliases[c.type]&&(c=B(c,this.normalize(this.aliases[c.type]),
{skipIfExists:!0}));c=B(c,this.defaults[c.type],{skipIfExist:!0});if("multi"===c.type)return c.rules=c.rules.map(function(d){return b.normalize(d)}),c.optional=c.rules.every(function(d){return!0===d.optional}),c;if("array"===c.type)return c.items=this.normalize(c.items),c;"object"===c.type&&c.props&&Object.entries(c.props).forEach(function(d){return c.props[d[0]]=b.normalize(d[1])});"object"===typeof a&&(a.type?(a=this.normalize(a.type),B(c,a,{skipIfExists:!0})):Object.entries(a).forEach(function(d){return c[d[0]]=
b.normalize(d[1])}));return c};return e}"object"===typeof exports&&"undefined"!==typeof module?module.exports=G():"function"===typeof define&&define.amd?define(G):(F="undefined"!==typeof globalThis?globalThis:F||self,F.FastestValidator=G())

@@ -911,2 +911,12 @@

/**
* consider null as a value?
*/
considerNullAsAValue?: boolean;
/**
* Immediately halt after the first error
*/
haltOnFirstError?: boolean
/**
* Default settings for rules

@@ -913,0 +923,0 @@ */

@@ -116,11 +116,22 @@ "use strict";

const src = [];
const {considerNullAsAValue = false} = this.opts;
let handleNoValue;
let skipUndefinedValue = rule.schema.optional === true || rule.schema.type === "forbidden";
let skipNullValue = rule.schema.optional === true || rule.schema.nullable === true || rule.schema.type === "forbidden";
let skipNullValue = considerNullAsAValue ?
rule.schema.nullable !== false || rule.schema.type === "forbidden" :
rule.schema.optional === true || rule.schema.nullable === true || rule.schema.type === "forbidden";
if (rule.schema.default != null) {
const ruleHasDefault = considerNullAsAValue ?
rule.schema.default != undefined && rule.schema.default != null :
rule.schema.default != undefined;
if (ruleHasDefault) {
// We should set default-value when value is undefined or null, not skip! (Except when null is allowed)
skipUndefinedValue = false;
if (rule.schema.nullable !== true) skipNullValue = false;
if (considerNullAsAValue) {
if (rule.schema.nullable === false) skipNullValue = false;
} else {
if (rule.schema.nullable !== true) skipNullValue = false;
}

@@ -508,7 +519,8 @@ let defaultValue;

// Check 'nullable' flag
const isNullable = schema.rules
const nullCheck = this.opts.considerNullAsAValue ? false : true;
const setNullable = schema.rules
.map(s => this.getRuleFromSchema(s))
.every(rule => rule.schema.nullable === true);
if (isNullable)
schema.nullable = true;
.every(rule => rule.schema.nullable === nullCheck);
if (setNullable)
schema.nullable = nullCheck;
}

@@ -515,0 +527,0 @@

{
"name": "fastest-validator",
"version": "1.16.0",
"version": "1.17.0",
"description": "The fastest JS validator library for NodeJS",

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

@@ -194,3 +194,29 @@ ![Photos from @ikukevk](https://user-images.githubusercontent.com/306521/30183963-9c722dca-941c-11e7-9e83-c78377ad7f9d.jpg)

```
### Considering `null` as a value
In specific case, you may want to consider `null` as a valid input even for a `required` field.
It's useful in cases you want a field to be:
- `required` and `null` without specifying `nullable: true` in its definition.
- `required` and not `null` by specifying `nullable: false` in its definition.
- `optional` **but specifically not** `null`.
To be able to achieve this you'll have to set the `considerNullAsAValue` validator option to `true`.
```js
const v = new Validator({considerNullAsAValue: true});
const schema = {foo: {type: "number"}, bar: {type: "number", optional: true, nullable: false}, baz: {type: "number", nullable: false}};
const check = v.compile(schema);
const object1 = {foo: null, baz: 1};
check(object1); // valid (foo is required and can be null)
const object2 = {foo: 3, bar: null, baz: 1};
check(object2); // not valid (bar is optional but can't be null)
const object3 = {foo: 3, baz: null};
check(object3); // not valid (baz is required but can't be null)
```
With this option set all fields will be considered _nullable_ by default.
# Strict validation

@@ -197,0 +223,0 @@ Object properties which are not specified on the schema are ignored by default. If you set the `$$strict` option to `true` any additional properties will result in an `strictObject` error.

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