skema
Version:
Skema provides a handy & composable way to validate / transform / purify the input data.
1 lines • 64.8 kB
JavaScript
"use strict";function _toArray(arr){return _arrayWithHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableRest()}function ownKeys(object,enumerableOnly){var symbols,keys=Object.keys(object);return Object.getOwnPropertySymbols&&(symbols=Object.getOwnPropertySymbols(object),enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)),keys}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))})}return target}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toConsumableArray(arr){return _arrayWithoutHoles(arr)||_iterableToArray(arr)||_unsupportedIterableToArray(arr)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(iter){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(iter))return Array.from(iter)}function _arrayWithoutHoles(arr){if(Array.isArray(arr))return _arrayLikeToArray(arr)}function _objectWithoutProperties(source,excluded){if(null==source)return{};var key,target=_objectWithoutPropertiesLoose(source,excluded);if(Object.getOwnPropertySymbols)for(var sourceSymbolKeys=Object.getOwnPropertySymbols(source),i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],0<=excluded.indexOf(key)||Object.prototype.propertyIsEnumerable.call(source,key)&&(target[key]=source[key]);return target}function _objectWithoutPropertiesLoose(source,excluded){if(null==source)return{};for(var key,target={},sourceKeys=Object.keys(source),i=0;i<sourceKeys.length;i++)key=sourceKeys[i],0<=excluded.indexOf(key)||(target[key]=source[key]);return target}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){return(_setPrototypeOf=Object.setPrototypeOf||function(o,p){return o.__proto__=p,o})(o,p)}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function(){var NewTarget,Super=_getPrototypeOf(Derived);return _possibleConstructorReturn(this,hasNativeReflectConstruct?(NewTarget=_getPrototypeOf(this).constructor,Reflect.construct(Super,arguments,NewTarget)):Super.apply(this,arguments))}}function _possibleConstructorReturn(self,call){return!call||"object"!==_typeof2(call)&&"function"!=typeof call?_assertThisInitialized(self):call}function _assertThisInitialized(self){if(void 0===self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return self}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function _getPrototypeOf(o){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)})(o)}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(o,minLen){if(o){if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);return"Object"===n&&o.constructor&&(n=o.constructor.name),"Map"===n||"Set"===n?Array.from(o):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(o,minLen):void 0}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _iterableToArrayLimit(arr,i){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(arr)){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Constructor}function _typeof2(obj){return(_typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}!function(f){"object"===("undefined"==typeof exports?"undefined":_typeof2(exports))&&"undefined"!=typeof module?module.exports=f():"function"==typeof define&&define.amd?define([],f):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Skema=f()}(function(){return function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){function isBuffer(obj){return!!obj.constructor&&"function"==typeof obj.constructor.isBuffer&&obj.constructor.isBuffer(obj)}module.exports=function(obj){return null!=obj&&(isBuffer(obj)||function(obj){return"function"==typeof obj.readFloatLE&&"function"==typeof obj.slice&&isBuffer(obj.slice(0,0))}(obj)||!!obj._isBuffer)}},{}],2:[function(require,module,exports){var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&¤tQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,function(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}process.nextTick=function(fun){var args=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],3:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],4:[function(require,module,exports){module.exports=function(arg){return arg&&"object"===_typeof2(arg)&&"function"==typeof arg.copy&&"function"==typeof arg.fill&&"function"==typeof arg.readUInt8}},{}],5:[function(require,module,exports){(function(process,global){var formatRegExp=/%[sdj%]/g;exports.format=function(f){if(!isString(f)){for(var objects=[],i=0;i<arguments.length;i++)objects.push(inspect(arguments[i]));return objects.join(" ")}for(var i=1,args=arguments,len=args.length,str=String(f).replace(formatRegExp,function(x){if("%%"===x)return"%";if(len<=i)return x;switch(x){case"%s":return String(args[i++]);case"%d":return Number(args[i++]);case"%j":try{return JSON.stringify(args[i++])}catch(_){return"[Circular]"}default:return x}}),x=args[i];i<len;x=args[++i])null!==x&&isObject(x)?str+=" "+inspect(x):str+=" "+x;return str},exports.deprecate=function(fn,msg){if(void 0===global.process)return function(){return exports.deprecate(fn,msg).apply(this,arguments)};if(!0===process.noDeprecation)return fn;var warned=!1;return function(){if(!warned){if(process.throwDeprecation)throw new Error(msg);process.traceDeprecation?console.trace(msg):console.error(msg),warned=!0}return fn.apply(this,arguments)}};var debugEnviron,debugs={};function inspect(obj,opts){var ctx={seen:[],stylize:stylizeNoColor};return 3<=arguments.length&&(ctx.depth=arguments[2]),4<=arguments.length&&(ctx.colors=arguments[3]),isBoolean(opts)?ctx.showHidden=opts:opts&&exports._extend(ctx,opts),void 0===ctx.showHidden&&(ctx.showHidden=!1),void 0===ctx.depth&&(ctx.depth=2),void 0===ctx.colors&&(ctx.colors=!1),void 0===ctx.customInspect&&(ctx.customInspect=!0),ctx.colors&&(ctx.stylize=stylizeWithColor),formatValue(ctx,obj,ctx.depth)}function stylizeWithColor(str,styleType){var style=inspect.styles[styleType];return style?"["+inspect.colors[style][0]+"m"+str+"["+inspect.colors[style][1]+"m":str}function stylizeNoColor(str,styleType){return str}function formatValue(ctx,value,recurseTimes){if(ctx.customInspect&&value&&isFunction(value.inspect)&&value.inspect!==exports.inspect&&(!value.constructor||value.constructor.prototype!==value)){var ret=value.inspect(recurseTimes,ctx);return isString(ret)||(ret=formatValue(ctx,ret,recurseTimes)),ret}var primitive=function(ctx,value){if(void 0===value)return ctx.stylize("undefined","undefined");if(isString(value)){var simple="'"+JSON.stringify(value).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return ctx.stylize(simple,"string")}if(isNumber(value))return ctx.stylize(""+value,"number");if(isBoolean(value))return ctx.stylize(""+value,"boolean");if(null===value)return ctx.stylize("null","null")}(ctx,value);if(primitive)return primitive;var keys=Object.keys(value),visibleKeys=function(array){var hash={};return array.forEach(function(val,idx){hash[val]=!0}),hash}(keys);if(ctx.showHidden&&(keys=Object.getOwnPropertyNames(value)),isError(value)&&(0<=keys.indexOf("message")||0<=keys.indexOf("description")))return formatError(value);if(0===keys.length){if(isFunction(value)){var name=value.name?": "+value.name:"";return ctx.stylize("[Function"+name+"]","special")}if(isRegExp(value))return ctx.stylize(RegExp.prototype.toString.call(value),"regexp");if(isDate(value))return ctx.stylize(Date.prototype.toString.call(value),"date");if(isError(value))return formatError(value)}var output,base="",array=!1,braces=["{","}"];return isArray(value)&&(array=!0,braces=["[","]"]),isFunction(value)&&(base=" [Function"+(value.name?": "+value.name:"")+"]"),isRegExp(value)&&(base=" "+RegExp.prototype.toString.call(value)),isDate(value)&&(base=" "+Date.prototype.toUTCString.call(value)),isError(value)&&(base=" "+formatError(value)),0!==keys.length||array&&0!=value.length?recurseTimes<0?isRegExp(value)?ctx.stylize(RegExp.prototype.toString.call(value),"regexp"):ctx.stylize("[Object]","special"):(ctx.seen.push(value),output=array?function(ctx,value,recurseTimes,visibleKeys,keys){for(var output=[],i=0,l=value.length;i<l;++i)hasOwnProperty(value,String(i))?output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,String(i),!0)):output.push("");return keys.forEach(function(key){key.match(/^\d+$/)||output.push(formatProperty(ctx,value,recurseTimes,visibleKeys,key,!0))}),output}(ctx,value,recurseTimes,visibleKeys,keys):keys.map(function(key){return formatProperty(ctx,value,recurseTimes,visibleKeys,key,array)}),ctx.seen.pop(),function(output,base,braces){if(60<output.reduce(function(prev,cur){return 0<=cur.indexOf("\n")&&0,prev+cur.replace(/\u001b\[\d\d?m/g,"").length+1},0))return braces[0]+(""===base?"":base+"\n ")+" "+output.join(",\n ")+" "+braces[1];return braces[0]+base+" "+output.join(", ")+" "+braces[1]}(output,base,braces)):braces[0]+base+braces[1]}function formatError(value){return"["+Error.prototype.toString.call(value)+"]"}function formatProperty(ctx,value,recurseTimes,visibleKeys,key,array){var name,str,desc=Object.getOwnPropertyDescriptor(value,key)||{value:value[key]};if(desc.get?str=desc.set?ctx.stylize("[Getter/Setter]","special"):ctx.stylize("[Getter]","special"):desc.set&&(str=ctx.stylize("[Setter]","special")),hasOwnProperty(visibleKeys,key)||(name="["+key+"]"),str||(ctx.seen.indexOf(desc.value)<0?-1<(str=formatValue(ctx,desc.value,null===recurseTimes?null:recurseTimes-1)).indexOf("\n")&&(str=array?str.split("\n").map(function(line){return" "+line}).join("\n").substr(2):"\n"+str.split("\n").map(function(line){return" "+line}).join("\n")):str=ctx.stylize("[Circular]","special")),void 0===name){if(array&&key.match(/^\d+$/))return str;name=(name=JSON.stringify(""+key)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(name=name.substr(1,name.length-2),ctx.stylize(name,"name")):(name=name.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ctx.stylize(name,"string"))}return name+": "+str}function isArray(ar){return Array.isArray(ar)}function isBoolean(arg){return"boolean"==typeof arg}function isNull(arg){return null===arg}function isNumber(arg){return"number"==typeof arg}function isString(arg){return"string"==typeof arg}function isUndefined(arg){return void 0===arg}function isRegExp(re){return isObject(re)&&"[object RegExp]"===objectToString(re)}function isObject(arg){return"object"===_typeof2(arg)&&null!==arg}function isDate(d){return isObject(d)&&"[object Date]"===objectToString(d)}function isError(e){return isObject(e)&&("[object Error]"===objectToString(e)||e instanceof Error)}function isFunction(arg){return"function"==typeof arg}function objectToString(o){return Object.prototype.toString.call(o)}function pad(n){return n<10?"0"+n.toString(10):n.toString(10)}exports.debuglog=function(set){var pid;return void 0===debugEnviron&&(debugEnviron=process.env.NODE_DEBUG||""),set=set.toUpperCase(),debugs[set]||(new RegExp("\\b"+set+"\\b","i").test(debugEnviron)?(pid=process.pid,debugs[set]=function(){var msg=exports.format.apply(exports,arguments);console.error("%s %d: %s",set,pid,msg)}):debugs[set]=function(){}),debugs[set]},(exports.inspect=inspect).colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},exports.isArray=isArray,exports.isBoolean=isBoolean,exports.isNull=isNull,exports.isNullOrUndefined=function(arg){return null==arg},exports.isNumber=isNumber,exports.isString=isString,exports.isSymbol=function(arg){return"symbol"===_typeof2(arg)},exports.isUndefined=isUndefined,exports.isRegExp=isRegExp,exports.isObject=isObject,exports.isDate=isDate,exports.isError=isError,exports.isFunction=isFunction,exports.isPrimitive=function(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"===_typeof2(arg)||void 0===arg},exports.isBuffer=require("./support/isBuffer");var months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function hasOwnProperty(obj,prop){return Object.prototype.hasOwnProperty.call(obj,prop)}exports.log=function(){var d,time;console.log("%s - %s",(d=new Date,time=[pad(d.getHours()),pad(d.getMinutes()),pad(d.getSeconds())].join(":"),[d.getDate(),months[d.getMonth()],time].join(" ")),exports.format.apply(exports,arguments))},exports.inherits=require("inherits"),exports._extend=function(origin,add){if(!add||!isObject(add))return origin;for(var keys=Object.keys(add),i=keys.length;i--;)origin[keys[i]]=add[keys[i]];return origin}}).call(this,require("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":4,_process:2,inherits:3}],6:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"LOOSE",{enumerable:!0,get:function(){return _loose.LOOSE}}),Object.defineProperty(exports,"STRICT",{enumerable:!0,get:function(){return _strict.STRICT}});var _loose=require("./loose"),_strict=require("./strict")},{"./loose":7,"./strict":8}],7:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.LOOSE=void 0;var _coreUtilIs=require("core-util-is"),LOOSE=[{name:["string",String],definition:{set:function(value){return void 0===value?"":String(value)}}},{name:["number",Number],definition:{set:function(value){var num=Number(value);if(num!=num)throw new TypeError("not a number");return num}}},{name:["boolean",Boolean],definition:{set:Boolean}},{name:["date",Date],definition:{set:function(value){if((0,_coreUtilIs.isNumber)(value)&&0<=value)return new Date(value);var date=Date.parse(value);if(date!=date)throw new TypeError("not a date");return new Date(date)}}},{name:["function",Function],definition:{validate:function(value){if((0,_coreUtilIs.isFunction)(value))return!0;throw new TypeError("not a function")}}},{name:["regexp",RegExp],definition:{set:function(value){if((0,_coreUtilIs.isRegExp)(value))return value;if((0,_coreUtilIs.isString)(value))return new RegExp(value);throw new TypeError("not a regular expression")}}},{name:["error",Error],definition:{set:function(value){return(0,_coreUtilIs.isError)(value)?value:new Error(value)}}},{name:["object",Object],definition:{set:Object}}];exports.LOOSE=LOOSE,"undefined"!=typeof Symbol&&LOOSE.push({name:["symbol",Symbol],definition:{set:function(value){return(0,_coreUtilIs.isSymbol)(value)?value:Symbol(value)}}})},{"core-util-is":9}],8:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.STRICT=void 0;var _coreUtilIs=require("core-util-is");function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}var STRICT=[];function D(name,Ctor,is,message){STRICT.push({name:[name,Ctor],definition:{validate:function(value){if(is(value))return!0;throw new TypeError(message)}}})}exports.STRICT=STRICT,D("string",String,_coreUtilIs.isString,"not a string"),D("number",Number,_coreUtilIs.isNumber,"not a number"),D("date",Date,_coreUtilIs.isDate,"not a date"),D("regexp",RegExp,_coreUtilIs.isRegExp,"not a regular expression"),D("object",Object,_coreUtilIs.isObject,"not an object"),D("function",Function,_coreUtilIs.isFunction,"not a function"),D("error",Error,_coreUtilIs.isError,"not an error"),void 0!==("undefined"==typeof Symbol?"undefined":_typeof(Symbol))&&D("symbol",Symbol,_coreUtilIs.isSymbol,"not a symbol")},{"core-util-is":9}],9:[function(require,module,exports){(function(Buffer){function objectToString(o){return Object.prototype.toString.call(o)}exports.isArray=function(arg){return Array.isArray?Array.isArray(arg):"[object Array]"===objectToString(arg)},exports.isBoolean=function(arg){return"boolean"==typeof arg},exports.isNull=function(arg){return null===arg},exports.isNullOrUndefined=function(arg){return null==arg},exports.isNumber=function(arg){return"number"==typeof arg},exports.isString=function(arg){return"string"==typeof arg},exports.isSymbol=function(arg){return"symbol"===_typeof2(arg)},exports.isUndefined=function(arg){return void 0===arg},exports.isRegExp=function(re){return"[object RegExp]"===objectToString(re)},exports.isObject=function(arg){return"object"===_typeof2(arg)&&null!==arg},exports.isDate=function(d){return"[object Date]"===objectToString(d)},exports.isError=function(e){return"[object Error]"===objectToString(e)||e instanceof Error},exports.isFunction=function(arg){return"function"==typeof arg},exports.isPrimitive=function(arg){return null===arg||"boolean"==typeof arg||"number"==typeof arg||"string"==typeof arg||"symbol"===_typeof2(arg)||void 0===arg},exports.isBuffer=Buffer.isBuffer}).call(this,{isBuffer:require("../../../../../node_modules/is-buffer/index.js")})},{"../../../../../node_modules/is-buffer/index.js":1}],10:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.Context=void 0;var _error=require("./error"),_util=require("./util"),_future=require("./future"),Context=function(){function Context(input){var key=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,parent=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,path=3<arguments.length&&void 0!==arguments[3]?arguments[3]:[];_classCallCheck(this,Context),this.input=input,this.rawKey=key,this.key=key,this.rawParent=parent,this.parent=null,this.path=path}return _createClass(Context,[{key:"descend",value:function(key){return new Context(this.input[key],key,this.input,this.path.concat(key))}},{key:"_wrap",value:function(error){return assign(error,"key",this.key),assign(error,"rawKey",this.rawKey),assign(error,"input",this.input),assign(error,"path",this.path),(0,_util.defineValue)(error,_future.TYPE_ERROR,!0),error}},{key:"makeError",value:function(error){if((0,_future.isError)(error))return error;var err=error instanceof Error?error:new Error(error);return assign(err,"code","CUSTOM_ERROR"),this._wrap(err)}},{key:"errorByCode",value:function(code){for(var _len=arguments.length,args=new Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var err=_error.error.apply(void 0,[code].concat(args));return this._wrap(err)}},{key:"context",get:function(){return{rawKey:this.rawKey,key:this.key,rawParent:this.rawParent,parent:this.parent,path:this.path,input:this.input}}}]),Context}();function assign(object,key,value){key in object||(object[key]=value)}exports.Context=Context},{"./error":12,"./future":13,"./util":22}],11:[function(require,module,exports){var obj,_error=require("./error"),_util=(obj=require("util"))&&obj.__esModule?obj:{default:obj};(0,_error.E)("REDECLARE_TYPE",{message:"type '%s' should not be declared again"}),(0,_error.E)("UNKNOWN_TYPE",{message:"unknown type '%s'",ctor:RangeError}),(0,_error.E)("INVALID_TYPE_NAME",{message:"invalid type name '%s'",ctor:TypeError}),(0,_error.E)("NON_ARRAY_TYPES",{message:"types must be an array",ctor:TypeError}),(0,_error.E)("EMPTY_ARRAY_TYPE",{message:"empty type array",ctor:TypeError}),(0,_error.E)("INVALID_TYPE",{message:"invalid type definition",ctor:TypeError}),(0,_error.E)("EMPTY_TYPE",{message:"`any()`` should be used instead of an empty type, or type alias not found",ctor:TypeError}),(0,_error.E)("INVALID_SETTER",{message:"invalid setter, only functions are accepted",ctor:TypeError}),(0,_error.E)("INVALID_VALIDATOR",{message:"invalid validator for '%s', only functions or regular expressions are accepted",ctor:TypeError}),(0,_error.E)("VALIDATION_FAILS",{message:function(value,key){return value=_util.default.inspect(value),key?_util.default.format("invalid value %s for key '%s'",value,key):_util.default.format("invalid value %s",value)}}),(0,_error.E)("ASSIGN_ASYNC",{message:"`set()` should be used to assign new value to property of async skema"}),(0,_error.E)("NOT_OPTIONAL",{message:function(key){return _util.default.format("property %s is not optional",_util.default.inspect(key))}}),(0,_error.E)("NOT_OBJECT",{message:function(key){return _util.default.format("the value of property %s is not an object",_util.default.inspect(key))}}),(0,_error.E)("NOT_WRITABLE",{message:"property '%s' is readonly"}),(0,_error.E)("SHAPE_NOT_FOUND",{message:"shape definition not found on the object"})},{"./error":12,util:5}],12:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.E=exports.error=void 0;var _errObject$Errors=new(require("err-object").Errors),E=_errObject$Errors.E,error=_errObject$Errors.error;exports.error=error,exports.E=E},{"err-object":24}],13:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.CUSTOM_INSPECT_SYMBOL=exports.SHAPE=exports.isError=exports.TYPE_ERROR=exports.isSkema=exports.TYPE_SKEMA=exports.symbol=exports.Types=void 0;var _error=require("./error"),_util=require("./util"),getTypeName=function(name){return(0,_util.isObject)(name)&&name.name||name},Types=function(){function Types(){_classCallCheck(this,Types),this._map=new WeakMap,this._hash=Object.create(null)}return _createClass(Types,[{key:"get",value:function(name,strict){var value=(0,_util.isObject)(name)?this._map.get(name):this._hash[name];if(strict&&!value)throw(0,_error.error)("UNKNOWN_TYPE",getTypeName(name));return value}},{key:"set",value:function(alias,skema){return(0,_util.isObject)(alias)?this._setMap(alias,skema):(0,_util.isString)(alias)?this._setHash(alias,skema):void 0}},{key:"_setMap",value:function(name,skema){if(this._map.has(name))return this._redefine(name);this._map.set(name,skema)}},{key:"_redefine",value:function(name){throw(0,_error.error)("REDECLARE_TYPE",getTypeName(name))}},{key:"_setHash",value:function(name,skema){if(name in this._hash)return this._redefine(name);this._hash[name]=skema}}]),Types}();exports.Types=Types;var symbol=Symbol,TYPE_SKEMA=(exports.symbol=symbol).for("skema");exports.TYPE_SKEMA=TYPE_SKEMA;exports.isSkema=function(subject){return!!subject&&!0===subject[TYPE_SKEMA]};var TYPE_ERROR=symbol.for("skema:error");exports.TYPE_ERROR=TYPE_ERROR;exports.isError=function(subject){return!!subject&&subject[TYPE_ERROR]};var SHAPE=symbol.for("skema:shape");exports.SHAPE=SHAPE;var CUSTOM_INSPECT_SYMBOL=symbol.for("nodejs.util.inspect.custom");exports.CUSTOM_INSPECT_SYMBOL=CUSTOM_INSPECT_SYMBOL},{"./error":12,"./util":22}],14:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"inspect",{enumerable:!0,get:function(){return _inspect.inspect}}),exports.BASIC_TYPES=exports.defaults=exports.declare=exports.any=exports.objectOf=exports.arrayOf=exports.shape=exports.type=void 0;var _basic=require("@skema/basic"),_skemaFactory=require("./skema-factory"),_inspect=require("./inspect");require("./error-meta");var _ref=(0,_skemaFactory.factory)({types:_basic.LOOSE}),type=_ref.type,shape=_ref.shape,arrayOf=_ref.arrayOf,objectOf=_ref.objectOf,any=_ref.any,declare=_ref.declare;exports.declare=declare,exports.any=any,exports.objectOf=objectOf,exports.arrayOf=arrayOf,exports.shape=shape,exports.type=type;var defaults=_skemaFactory.factory;exports.defaults=defaults;var BASIC_TYPES={LOOSE:_basic.LOOSE,STRICT:_basic.STRICT};exports.BASIC_TYPES=BASIC_TYPES},{"./error-meta":11,"./inspect":15,"./skema-factory":19,"@skema/basic":6}],15:[function(require,module,exports){(function(process){Object.defineProperty(exports,"__esModule",{value:!0}),exports.attach=exports.inspect=void 0;var _coreUtilIs=require("core-util-is"),_future=require("./future"),_util=require("./util"),isNode=void 0!==process,inspect=function(subject){return(0,_util.isObject)(subject)&&subject[_future.SHAPE]?inspectSkemaObject(subject):subject};exports.inspect=inspect;var inspectSkemaObject=function(object){return Object.keys(object[_future.SHAPE]).reduce(function(ret,key){return ret[key]=inspect(object[key]),ret},(0,_coreUtilIs.isArray)(object)?[]:{})};function inspectSelf(){return inspectSkemaObject(this)}var attach=isNode?function(object){(0,_util.defineValue)(object,_future.CUSTOM_INSPECT_SYMBOL,inspectSelf)}:_util.NOOP;exports.attach=attach}).call(this,require("_process"))},{"./future":13,"./util":22,_process:2,"core-util-is":23}],16:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.Options=void 0;var obj,_promiseFaker=(obj=require("promise-faker"))&&obj.__esModule?obj:{default:obj},_promise=require("promise.extra");var promiseExtra={series:_promise.series,waterfall:_promise.waterfall},IS_DEFAULT=function(rawParent,key){return!(key in rawParent)};exports.Options=function Options(_ref2){var _ref2$async=_ref2.async,async=void 0!==_ref2$async&&_ref2$async,_ref2$isDefault=_ref2.isDefault,isDefault=void 0===_ref2$isDefault?IS_DEFAULT:_ref2$isDefault;_classCallCheck(this,Options),this.promise=async?Promise:_promiseFaker.default,this.promiseExtra=async?promiseExtra:(0,_promise.factory)(_promiseFaker.default),this.async=async,this.isDefault=isDefault}},{"promise-faker":29,"promise.extra":30}],17:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.Processor=void 0;require("./options");var _future=require("./future"),_util=require("./util"),config=function(skema,name){var value=skema[(0,_util.getKey)(name,_util.PREFIX_IS)]();return!(0,_util.isDefined)(value)||value},Processor=function(){function Processor(options){_classCallCheck(this,Processor),Object.assign(this,options);var _this$context=this.context,key=_this$context.key,rawParent=_this$context.rawParent,input=_this$context.input,isDefault=this.options.isDefault;this.isDefault=isDefault(rawParent,key),this.input=input,this.set=null}return _createClass(Processor,[{key:"mapKey",value:function(){var skema=this.skema,options=this.options,context=this.context,key=skema.hasKey()?skema.key(this.args,context,options):context.key;return options.promise.resolve(key)}},{key:"make",value:function(){var values=this.values,skema=this.skema,args=this.args,context=this.context,options=this.options,key=context.key,input=context.input,symbolKey=(0,_future.symbol)(key);!function(object,key){(0,_util.defineProperty)(object,key,{writable:!0})}(values,symbolKey),this._clean||(values[symbolKey]=input);var writable=config(skema,"writable"),set=this.set=this.setters[key]=function(value,force,c){if((c=c||context).input=value,!writable&&!force)throw c.errorByCode("NOT_WRITABLE",key);var result=skema.f(args,c,options).then(function(value){return values[symbolKey]=value});return options.promise.resolve(result,!0)};(0,_util.defineProperty)(values,key,{set:options.async?function(){throw context.errorByCode("ASSIGN_ASYNC")}:function(v){return set(v)},get:function(){return values[symbolKey]},configurable:config(skema,"configurable"),enumerable:config(skema,"enumerable")})}},{key:"process",value:function(){var _this=this;return this.mapKey().then(function(key){return _this.context.key=key,_this.make(),_this.shouldSkip()}).then(function(skip){if(!skip)return _this.set(_this.input,!0)})}},{key:"shouldSkip",value:function(){var _this2=this,skema=this.skema;return skema.hasWhen()?skema.when(this.args,this.context,this.options).then(function(hit){return!hit||_this2._shouldSkip()}):this._shouldSkip()}},{key:"_shouldSkip",value:function(){var _this3=this,skema=this.skema;if(!this.isDefault)return!1;if(!skema.isOptional())throw this.context.errorByCode("NOT_OPTIONAL",this.context.rawKey);return!skema.hasDefault()||skema.default(this.args,this.context,this.options).then(function(value){return _this3.input=value,!1})}}]),Processor}();exports.Processor=Processor},{"./future":13,"./options":16,"./util":22}],18:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArrayOfShape=exports.ObjectOfShape=exports.ArrayShape=exports.ObjectShape=exports.set=exports.TYPE_ARRAY=exports.TYPE_OBJECT=void 0;var _util=require("./util"),_processor=require("./processor"),_context=require("./context"),_error=require("./error"),_future=require("./future"),_inspect=require("./inspect");exports.TYPE_OBJECT="TYPE_OBJECT";exports.TYPE_ARRAY="TYPE_ARRAY";function clean(context){context.rawParent=context.parent=null}exports.set=function(object,key,value){var setters=object[_future.SHAPE],setter=setters&&setters[key],context=new _context.Context(value,key,object,[key]);if(context.parent=object,!setter)throw(0,_error.error)("SHAPE_NOT_FOUND");return setter(value,!1,context)};function reducer(prev,factory){return factory.call(this,prev)}var Shape=function(){function Shape(shape,clean){_classCallCheck(this,Shape),this._shape=shape,this._clean=clean}return _createClass(Shape,[{key:"from",value:function(args,parentContext,options){var v,_this4=this;if(v=parentContext.input,Object(v)!==v){var error=parentContext.errorByCode("NOT_OBJECT",parentContext.key);return options.promise.reject(error)}var values=this._create(parentContext),setters=Object.create(null);(0,_util.defineValue)(values,_future.SHAPE,setters),(0,_inspect.attach)(values);var tasks=this._taskKeys(parentContext).map(function(key){return function(){var _this4$_task2=_slicedToArray(_this4._task(key,parentContext),2),context=_this4$_task2[0],skema=_this4$_task2[1];return context.parent=values,new _processor.Processor({options:options,skema:skema,args:args,context:context,values:values,setters:setters}).process().then(function(){return clean(context)},function(error){return clean(context),options.promise.reject(error)})}});return options.promiseExtra.series(tasks,reducer).then(function(){return values})}}]),Shape}(),GenericObjectShape=function(){_inherits(GenericObjectShape,Shape);var _super=_createSuper(GenericObjectShape);function GenericObjectShape(){return _classCallCheck(this,GenericObjectShape),_super.apply(this,arguments)}return _createClass(GenericObjectShape,[{key:"_task",value:function(key,context){return[context.descend(key),this._shape[key]]}}]),GenericObjectShape}(),ObjectShape=function(){_inherits(ObjectShape,GenericObjectShape);var _super2=_createSuper(ObjectShape);function ObjectShape(){return _classCallCheck(this,ObjectShape),_super2.apply(this,arguments)}return _createClass(ObjectShape,[{key:"_create",value:function(context){return this._clean?Object.create(null):(0,_util.simpleClone)(context.input)}},{key:"_taskKeys",value:function(){return Object.keys(this._shape)}}]),ObjectShape}();exports.ObjectShape=ObjectShape;var ArrayShape=function(){_inherits(ArrayShape,GenericObjectShape);var _super3=_createSuper(ArrayShape);function ArrayShape(){return _classCallCheck(this,ArrayShape),_super3.apply(this,arguments)}return _createClass(ArrayShape,[{key:"_create",value:function(_ref3){var input=_ref3.input;return this._clean?[]:[].concat(input)}},{key:"_taskKeys",value:function(){return this._shape.map(function(_,i){return i})}}]),ArrayShape}();exports.ArrayShape=ArrayShape;var GenericOfShape=function(){_inherits(GenericOfShape,Shape);var _super4=_createSuper(GenericOfShape);function GenericOfShape(){return _classCallCheck(this,GenericOfShape),_super4.apply(this,arguments)}return _createClass(GenericOfShape,[{key:"_task",value:function(key,context){return[context.descend(key),this._shape]}}]),GenericOfShape}(),ObjectOfShape=function(){_inherits(ObjectOfShape,GenericOfShape);var _super5=_createSuper(ObjectOfShape);function ObjectOfShape(){return _classCallCheck(this,ObjectOfShape),_super5.apply(this,arguments)}return _createClass(ObjectOfShape,[{key:"_create",value:function(){return Object.create(null)}},{key:"_taskKeys",value:function(_ref4){var input=_ref4.input;return Object.keys(input)}}]),ObjectOfShape}();exports.ObjectOfShape=ObjectOfShape;var ArrayOfShape=function(){_inherits(ArrayOfShape,GenericOfShape);var _super6=_createSuper(ArrayOfShape);function ArrayOfShape(){return _classCallCheck(this,ArrayOfShape),_super6.apply(this,arguments)}return _createClass(ArrayOfShape,[{key:"_create",value:function(){return[]}},{key:"_taskKeys",value:function(_ref5){for(var tasks=[],length=_ref5.input.length,i=0;i<length;i++)tasks.push(i);return tasks}}]),ArrayOfShape}();exports.ArrayOfShape=ArrayOfShape},{"./context":10,"./error":12,"./future":13,"./inspect":15,"./processor":17,"./util":22}],19:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.factory=void 0;var obj,_class,_skema=require("./skema"),_future=require("./future"),_options=require("./options"),_makeArray=(obj=require("make-array"))&&obj.__esModule?obj:{default:obj},_error=require("./error"),_util=require("./util"),_type2=require("./type"),_shape=require("./shape");var target,property,decorators,descriptor,context,desc,METHODS=["type","shape","objectOf","arrayOf","any","declare"],REGEX_ENDS_QUESTION_MARK=/\?$/,validateTypeName=function(name){return(0,_util.isObject)(name)?name:function(name){if(!(0,_util.isString)(name)||REGEX_ENDS_QUESTION_MARK.test(name=name.trim()))throw(0,_error.error)("INVALID_TYPE_NAME",name);return name}(name)},SkemaFactory=(target=(_class=function(){function SkemaFactory(options){var _this5=this;_classCallCheck(this,SkemaFactory),METHODS.forEach(function(method){_this5[method]=_this5[method].bind(_this5)});var _options$types=options.types,types=void 0===_options$types?[]:_options$types,others=_objectWithoutProperties(options,["types"]);if(this._options=new _options.Options(others),this._types=new _future.Types,!(0,_util.isArray)(types))throw(0,_error.error)("NON_ARRAY_TYPES");types.forEach(function(_ref6){var name=_ref6.name,definition=_ref6.definition;_this5.declare(name,definition)})}return _createClass(SkemaFactory,[{key:"set",value:function(){return _shape.set.apply(void 0,arguments)}},{key:"type",value:function(def){if((0,_future.isSkema)(def))return def;if((0,_util.isString)(def))return this._stringType(def);if((0,_util.isObject)(def))return this._type(def);throw(0,_error.error)("INVALID_TYPE")}},{key:"_type",value:function(def){var definition=new _type2.TypeDefinition(def);return definition._type&&(definition._type=this.type(definition._type)),this._create(definition)}},{key:"shape",value:function(_shape2,clean){return this._create({_shape:(0,_util.isArray)(_shape2)?new _shape.ArrayShape(this._arrayShape(_shape2),clean):new _shape.ObjectShape(this._objectShape(_shape2),clean)})}},{key:"objectOf",value:function(type){return this._create({_shape:new _shape.ObjectOfShape(this.type(type))})}},{key:"arrayOf",value:function(type){return this._create({_shape:new _shape.ArrayOfShape(this.type(type))})}},{key:"any",value:function(){return this._create({_any:!0})}},{key:"declare",value:function(name,definition){var _this6=this,names=(0,_makeArray.default)(name).map(validateTypeName),skema=this.type(definition);names.forEach(function(name){return _this6._types.set(name,skema)})}},{key:"_stringType",value:function(string){string=string.trim();var hasOptionalMark=REGEX_ENDS_QUESTION_MARK.test(string);hasOptionalMark&&(string=string.slice(0,string.length-1).trimRight());var skema=this._types.get(string,!0);return!hasOptionalMark||skema.isOptional()?skema:this.type({type:skema,optional:!0})}},{key:"_arrayShape",value:function(array){var _this7=this;return array.map(function(type){return _this7.type(type)})}},{key:"_objectShape",value:function(shape){var _this8=this,skemaMap={};return Object.keys(shape).forEach(function(key){skemaMap[key]=_this8.type(shape[key])}),skemaMap}},{key:"_create",value:function(definition){return definition._options=this._options,new _skema.Skema(definition)}}]),SkemaFactory}()).prototype,property="_type",decorators=[function(target,key,descriptor){var original=descriptor.value;return descriptor.value=function(arg){var value=this._types.get(arg);if((0,_util.isDefined)(value))return value;if(0===Object.keys(arg).length)throw(0,_error.error)("EMPTY_TYPE");var created=original.call(this,arg);return this._types.set(arg,created),created},descriptor}],descriptor=Object.getOwnPropertyDescriptor(_class.prototype,"_type"),context=_class.prototype,desc={},Object.keys(descriptor).forEach(function(key){desc[key]=descriptor[key]}),desc.enumerable=!!desc.enumerable,desc.configurable=!!desc.configurable,("value"in desc||desc.initializer)&&(desc.writable=!0),desc=decorators.slice().reverse().reduce(function(desc,decorator){return decorator(target,property,desc)||desc},desc),context&&void 0!==desc.initializer&&(desc.value=desc.initializer?desc.initializer.call(context):void 0,desc.initializer=void 0),void 0===desc.initializer&&(Object.defineProperty(target,property,desc),desc=null),_class);exports.factory=function(argument_0){return new SkemaFactory(0<arguments.length&&void 0!==argument_0?argument_0:{})}},{"./error":12,"./future":13,"./options":16,"./shape":18,"./skema":20,"./type":21,"./util":22,"make-array":27}],20:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.Skema=void 0;var _context=require("./context"),_util=require("./util"),_future=require("./future"),_options=require("./options");function hasArray(key){var value=this["_"+key];return(0,_util.isDefined)(value)&&0!==value.length}var Skema=function(){function Skema(definition){_classCallCheck(this,Skema),Object.assign(this,definition),(0,_util.defineValue)(this,_future.TYPE_SKEMA,!0),this._hasV=hasArray.call(this,"validate"),this._hasS=hasArray.call(this,"set"),this._nw=this._hasV||this._hasS}return _createClass(Skema,[{key:"from",value:function(raw,args,options){return(0,_util.isObject)(args)&&(0,_util.isArray)(args)||(options=args,args=[]),(options=options?new _options.Options(options):this._options).promise.resolve(this.f(args,new _context.Context(raw),options),!0)}},{key:"f",value:function(args,context,options){var _this9=this,input=context.input;return this._any?options.promise.resolve(input):(0,_util.isDefined)(this._shape)?this._shape.from(args,context,options):this._nw?this.validate(args,context,options).then(function(){return _this9.set(args,context,options)}):this._type?this._type.f(args,context,options):options.promise.resolve(input)}},{key:"_c",value:function(key){var value=this["_"+key];return(0,_util.isDefined)(value)?value:this._type?this._type[(0,_util.getKey)(key,_util.PREFIX_IS)]():_util.UNDEFINED}},{key:"_has",value:function(key){return(0,_util.isDefined)(this["_"+key])||!!this._type&&this._type[(0,_util.getKey)(key,_util.PREFIX_HAS)]()}},{key:"isConfigurable",value:function(){return this._c("configurable")}},{key:"isEnumerable",value:function(){return this._c("enumerable")}},{key:"isWritable",value:function(){return this._c("writable")}},{key:"isOptional",value:function(){return!0===this._optional||!1!==this._optional&&this._type&&this._type.isOptional()}},{key:"hasWhen",value:function(){return this._has("when")}},{key:"when",value:function(args,context,options){return(0,_util.isDefined)(this._when)?options.promise.resolve(this._when.apply(context.context,args)):this._type.hasWhen()?this._type.when(args,context,options):void 0}},{key:"hasDefault",value:function(){return this._has("default")}},{key:"default",value:function(args,context,options){return(0,_util.isDefined)(this._default)?options.promise.resolve(this._default.apply(context.context,args)):this._type.hasDefault()?this._type.default(args,context,options):void 0}},{key:"hasKey",value:function(){return this._has("key")}},{key:"key",value:function(args,context,options){if((0,_util.isDefined)(this._key)){var _this$_key,key=context.key;return options.promise.resolve((_this$_key=this._key).call.apply(_this$_key,[context.context,key].concat(_toConsumableArray(args))))}if(this._type.hasKey())return this._type.key(args,context,options)}},{key:"validate",value:function(args,context,options){var _this10=this,promise=options.promise;return(this._type?this._type.validate(args,context,options):promise.resolve(!0)).then(function(pass){return pass&&_this10._hasV?options.promiseExtra.series.call(context.context,_this10._validate,function(_,factory){var input=context.input;return promise.resolve(factory.call.apply(factory,[this,input].concat(_toConsumableArray(args)))).then(function(pass){if(!1===pass)throw context.errorByCode("VALIDATION_FAILS",input,context.context.key);return!0})}).catch(function(error){return promise.reject(context.makeError(error))}):pass})}},{key:"set",value:function(args,context,options){var _this11=this,promise=options.promise,start=this._type?this._type.set(args,context,options):promise.resolve(context.input);return this._hasS?start.then(function(value){return options.promiseExtra.waterfall.call(context.context,_this11._set,value,function(prev,factory){return factory.call.apply(factory,[this,prev].concat(_toConsumableArray(args)))}).catch(function(error){return promise.reject(context.makeError(error))})}):start}}]),Skema}();exports.Skema=Skema},{"./context":10,"./future":13,"./options":16,"./util":22}],21:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.TypeDefinition=void 0;var _util=require("./util");exports.TypeDefinition=function TypeDefinition(definition){_classCallCheck(this,TypeDefinition);var _default=definition.default,set=definition.set,validate=definition.validate,when=definition.when,configurable=definition.configurable,enumerable=definition.enumerable,writable=definition.writable,optional=definition.optional,type=definition.type,key=definition.key;this._default=(0,_util.parseFunction)(_default),this._set=(0,_util.parseSetters)(set),this._validate=(0,_util.parseValidators)(validate),this._when=(0,_util.parseWhen)(when),this._key=(0,_util.parseFunction)(key),this._configurable=configurable,this._enumerable=enumerable,this._writable=writable,this._optional=!!(0,_util.isDefined)(this._default)||optional,this._type=type}},{"./util":22}],22:[function(require,module,exports){Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseFunction=exports.parseWhen=exports.parseSetters=exports.parseValidators=exports.parseValidator=exports.simpleClone=exports.getKey=exports.defineValue=exports.isArray=exports.isDefined=exports.isObject=exports.isRegExp=exports.isFunction=exports.isString=exports.NOOP=exports.PREFIX_HAS=exports.PREFIX_IS=exports.UNDEFINED=exports.defineProperty=void 0;var obj,_makeArray=(obj=require("make-array"))&&obj.__esModule?obj:{default:obj},_error=require("./error");var defineProperty=Object.defineProperty;exports.defineProperty=defineProperty;exports.UNDEFINED=void 0;exports.PREFIX_IS="is";exports.PREFIX_HAS="has";exports.NOOP=function(){};exports.isString=function(subject){return"string"==typeof subject};var isFunction=function(subject){return"function"==typeof subject};exports.isFunction=isFunction;var isRegExp=function(subject){return!!subject&&"function"==typeof subject.test};exports.isRegExp=isRegExp;exports.isObject=function(subject){return!!subject&&Object(subject)===subject};var isDefined=function(subject){return void 0!==subject};exports.isDefined=isDefined;var isArray=Array.isArray;exports.isArray=isArray;exports.defineValue=function(object,key,value){return defineProperty(object,key,{value:value})};exports.getKey=function(key,prefix){return prefix+function(key){return key[0].toUpperCase()+key.slice(1)}(key)};exports.simpleClone=function(object){return Object.assign(Object.create(null),object)};var parseValidator=function(validator){if(isFunction(validator))return validator;if(isRegExp(validator))return function(v){return validator.test(v)};throw(0,_error.error)("INVALID_VALIDATOR")};exports.parseValidator=parseValidator;exports.parseValidators=function(validators){if(validators)return(0,_makeArray.default)(validators).map(parseValidator)};exports.parseSetters=function(setters){if(setters)return(0,_makeArray.default)(setters).map(function(setter){if(isFunct