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

z-schema

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

z-schema - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

2

package.json

@@ -34,3 +34,3 @@ {

"files": ["src/ZSchema.js", "src/ZSchema.min.js", "LICENSE", "README.md"],
"version": "2.0.5",
"version": "2.1.0",
"dependencies": {

@@ -37,0 +37,0 @@ "q": "0.9.7"

@@ -228,2 +228,8 @@ # z-schema validator

## More options
* noSchemaCache: ```true/false```
when true, disables caching of compiled schemas - cache is used to resolve references to other schemas by their ID
# Pull requests

@@ -230,0 +236,0 @@

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

/*! z-schema version 2.0.5 */
!function(){"use strict";function a(a){this.options=d.defaults(a||{},{noExtraKeywords:!1,noZeroLengthStrings:!1,noTypeless:!1,forceAdditional:!1,forceProperties:!1,forceItems:!1,forceMaxLength:!1}),this.options.strict===!0&&(this.options.noExtraKeywords=!0,this.options.noZeroLengthStrings=!0,this.options.noTypeless=!0,this.options.forceAdditional=!0,this.options.forceProperties=!0,this.options.forceItems=!0,this.options.forceMaxLength=!0)}var b=require("q"),c=function(a,b,c,d){this.code=a,this.message=b,this.path=d||"",this.params=c||{}};c.prototype=new Error,c.messages={INVALID_TYPE:"invalid type: {type} (expected {expected})",ENUM_MISMATCH:"No enum match for: {value}",ANY_OF_MISSING:'Data does not match any schemas from "anyOf"',ONE_OF_MISSING:'Data does not match any schemas from "oneOf"',ONE_OF_MULTIPLE:'Data is valid against more than one schema from "oneOf"',NOT_PASSED:'Data matches schema from "not"',UNRESOLVABLE_REFERENCE:"Reference could not be resolved: {ref}",MULTIPLE_OF:"Value {value} is not a multiple of {multipleOf}",MINIMUM:"Value {value} is less than minimum {minimum}",MINIMUM_EXCLUSIVE:"Value {value} is equal or less than exclusive minimum {minimum}",MAXIMUM:"Value {value} is greater than maximum {maximum}",MAXIMUM_EXCLUSIVE:"Value {value} is equal or greater than exclusive maximum {maximum}",MIN_LENGTH:"String is too short ({length} chars), minimum {minimum}",MAX_LENGTH:"String is too long ({length} chars), maximum {maximum}",PATTERN:"String does not match pattern: {pattern}",OBJECT_PROPERTIES_MINIMUM:"Too few properties defined ({count}), minimum {minimum}",OBJECT_PROPERTIES_MAXIMUM:"Too many properties defined ({count}), maximum {maximum}",OBJECT_REQUIRED:"Missing required property: {property}",OBJECT_ADDITIONAL_PROPERTIES:"Additional properties not allowed",OBJECT_DEPENDENCY_KEY:"Dependency failed - key must exist: {missing} (due to key: {key})",ARRAY_LENGTH_SHORT:"Array is too short ({length}), minimum {minimum}",ARRAY_LENGTH_LONG:"Array is too long ({length}), maximum {maximum}",ARRAY_UNIQUE:"Array items are not unique (indices {index1} and {index2})",ARRAY_ADDITIONAL_ITEMS:"Additional items not allowed",FORMAT:"{format} format validation failed: {error}",KEYWORD_TYPE_EXPECTED:'Keyword "{keyword}" is expected to be type of type "{type}"',KEYWORD_UNDEFINED_STRICT:'Keyword "{keyword}" must be defined in strict mode',KEYWORD_UNEXPECTED:'Keyword "{keyword}" is not expected to appear in the schema',KEYWORD_MUST_BE:'Keyword "{keyword}" must be {expression}',KEYWORD_DEPENDENCY:'Keyword "{keyword1}" requires keyword "{keyword2}"',KEYWORD_PATTERN:'Keyword "{keyword}" is not a valid RegExp pattern ({pattern})',KEYWORD_VALUE_TYPE:'Each element of keyword "{keyword}" array must be a "{type}"',UNKNOWN_FORMAT:'There is no validation function for format "{format}"'},c.prototype.addSubError=function(a){this.subErrors||(this.subErrors=[]),this.subErrors.push(a)},c.createError=function(a,b,d){var e=c.messages[a];if(b=b||{},"string"!=typeof e)throw new Error("Unknown error code: "+a);return e=e.replace(/\{([^{}]*)\}/g,function(a,c){var d=b[c];return"string"==typeof d||"number"==typeof d?d:d&&"function"==typeof d.toString?d.toString():a}),new c(a,e,b,d)};var d={isBoolean:function(a){return"boolean"==typeof a},isString:function(a){return"string"==typeof a},isInteger:function(a){return this.isNumber(a)&&0===a%1},isNumber:function(a){return"number"==typeof a&&Number.isFinite(a)},isArray:function(a){return Array.isArray(a)},isObject:function(a){return"object"==typeof a&&a===Object(a)&&!Array.isArray(a)},isFunction:function(a){return"function"==typeof a},whatIs:function(a){if(void 0===a)return"undefined";if(null===a)return"null";if(this.isBoolean(a))return"boolean";if(this.isString(a))return"string";if(this.isArray(a))return"array";if(this.isInteger(a))return"integer";if(this.isNumber(a))return"number";if(this.isObject(a))return"object";if(this.isFunction(a))return"function";if(Number.isNaN(a))return"not-a-number";throw new Error("Utils.whatIs does not know what this is: "+a)},isUniqueArray:function(a,b){b=b||{};var c,d,e=a.length;for(c=0;e>c;c++)for(d=c+1;e>d;d++)if(this.areEqual(a[c],a[d]))return b.index1=c,b.index2=d,!1;return!0},keys:function(a){var b,c=[];for(b in a)a.hasOwnProperty(b)&&c.push(b);return c},forEach:function(a,b,c){if(Array.isArray(a))return a.forEach(b,c);if(d.isObject(a)){var e;for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e)}},map:function(a,b,c){var e=-1,f=[];return d.forEach(a,function(a,d){f[++e]=b.call(c,a,d)}),f},defaults:function(a,b){return d.forEach(b,function(b,c){void 0===a[c]&&(a[c]=b)}),a},uniq:function(a){var b=[];return a.forEach(function(a){-1===b.indexOf(a)&&b.push(a)}),b},difference:function(a,b){var c=[];return a.forEach(function(a){-1===b.indexOf(a)&&c.push(a)}),c},areEqual:function(a,b){if(a===b)return!0;var c,d;if(this.isArray(a)&&this.isArray(b)){if(a.length!==b.length)return!1;for(d=a.length,c=0;d>c;c++)if(!this.areEqual(a[c],b[c]))return!1;return!0}if(this.isObject(a)&&this.isObject(b)){var e=this.keys(a),f=this.keys(b);if(!this.areEqual(e,f))return!1;for(d=e.length,c=0;d>c;c++)if(!this.areEqual(a[e[c]],b[e[c]]))return!1;return!0}return!1},decodeJSONPointer:function(a){return decodeURIComponent(a).replace(/~[0-1]/g,function(a){return"~1"===a?"/":"~"})},_getRegExpCache:{},getRegExp:function(a){return this._getRegExpCache[a]||(this._getRegExpCache[a]=new RegExp(a)),this._getRegExpCache[a]},_getRemoteSchemaCache:{},getRemoteSchema:function(a,b){function c(a){var c=JSON.parse(a);c.id||(c.id=d),c.$schema||(c.$schema=d),b(void 0,c)}var d=a.split("#")[0];if(this._getRemoteSchemaCache[d])return c(this._getRemoteSchemaCache[d]),void 0;var e=this,f=require("http");f.get(d,function(a){var b="";a.on("data",function(a){b+=a}),a.on("end",function(){c(e._getRemoteSchemaCache[d]=b)})}).on("error",function(a){b(a)})},resolveSchemaQuery:function(b,c,e,f){if(a.expect.string(e),"#"===e)return c;var g=null,h=e.split("#")[0],i=e.split("#")[1];if(h)if(0===h.indexOf("http:")||0===h.indexOf("https:")){if(!c.__remotes||!c.__remotes[h])throw new Error("Remote is not downloaded: "+h);g=c.__remotes[h]}else g=d.resolveSchemaId(c,h);else g=c;if(g&&i)for(var j=("#"+i).split("/");j.length>0;){var k=d.decodeJSONPointer(j.shift());-1===k.indexOf("#")?g=g[k]:"#"!==k&&(g=d.resolveSchemaId(g,k))}if(!g&&!f)throw new Error("Could not resolve schema reference: "+e);return g},resolveSchemaId:function(a,b){if(this.isObject(a)||this.isArray(a)){if(a.id===b)return a;var c=null;return d.forEach(a,function(a){c||(c=d.resolveSchemaId(a,b))}),c}}},e={date:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$").exec(a);if(null===b)return!1;var c=b[2],e=b[3];return"01">c||c>"12"||"01">e||e>"31"?!1:!0},"date-time":function(a){if(!d.isString(a))return!0;var b=a.toLowerCase().split("t");if(!e.date(b[0]))return!1;var c=d.getRegExp("^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$").exec(b[1]);if(null===c)return!1;var f=c[1],g=c[2],h=c[3];return f>"23"||g>"59"||h>"59"?!1:!0},email:function(a){if(!d.isString(a))return!0;var b=d.getRegExp(/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i);return b.test(a)},hostname:function(a){if(!d.isString(a))return!0;if(-1===a.indexOf("."))return!1;var b=d.getRegExp("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$");return b.test(a)},"host-name":function(){return e.hostname.apply(this,arguments)},ipv4:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");return b.test(a)},ipv6:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$");return b.test(a)},uri:function(a){if(!d.isString(a))return!0;var b=new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:/[^\\s]*)?$","i");return b.test(a)}},f={},g=function(a){a&&(this.parentReport=a,d.forEach(a,function(a,b){this[b]=a},this)),this.errors=[],this.warnings=[],this.path=[]};g.prototype={getPath:function(){var a=["#"];return this.parentReport&&(a=a.concat(this.parentReport.path)),a=a.concat(this.path),1==a.length?"#/":a.join("/")},addWarning:function(a){return this.warnings.push({message:a,path:this.getPath()}),!0},addError:function(a,b,d){var e=c.createError(a,b,this.getPath());return d&&d.forEach(function(a){a.errors.forEach(function(a){e.addSubError(a)},this)},this),this.errors.push(e),!1},expect:function(a,b,c,d){return a?!0:(this.addError(b,c,d),!1)},isValid:function(){return 0===this.errors.length},toJSON:function(){return{valid:0===this.errors.length,errors:this.errors,warnings:this.warnings}},toError:function(){var a=new Error("Validation failed");return a.errors=this.errors,a.warnings=this.warnings,a},toPromise:function(){return this.isValid()?b(this):b.reject(this.toError())},goDown:function(a){this.path.push(a)},goUp:function(){this.path.pop()}},a.expect={typeError:function(a,b){return'Type mismatch, expected "'+a+'", got "'+d.whatIs(b)+'"'},"boolean":function(b){if(!d.isBoolean(b))throw new Error(a.expect.typeError("boolean",b))},string:function(b){if(!d.isString(b))throw new Error(a.expect.typeError("string",b))},callable:function(b){if(!d.isFunction(b))throw new Error(a.expect.typeError("function",b))},object:function(b){if(!d.isObject(b))throw new Error(a.expect.typeError("object",b))}},a.validate=function(){if(!this._defaultInstance){var a=this;this._defaultInstance=new a}return this._defaultInstance.validate.apply(this._defaultInstance,arguments)},a.registerFormat=function(b,c){if(a.expect.string(b),a.expect.callable(c),e[b])throw new Error("Cannot override built-in validator for "+b);if(f[b])throw new Error("Cannot override existing validator for "+b);f[b]=c},a.setRemoteReference=function(b,c){a.expect.string(c),d._getRemoteSchemaCache[b]=c},a.prototype.validate=function(a,b,c){var d=this,e=new g;return this._compileSchema(e,b).then(function(b){return d._validateSchema(e,b).then(function(){return d._validateObject(e,b,a).then(function(){return e.toPromise()})})}).then(function(){return e.toJSON()}).nodeify(c)},a.prototype.compileSchema=function(a,b){var c=this,d=new g;return this._compileSchema(d,a).then(function(a){return c._validateSchema(d,a).then(function(){return a})}).nodeify(b)},a.prototype.validateSchema=function(a,b){var c=new g;return this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},a.prototype._collectReferences=function j(a){var b=[];return a.$ref&&b.push(a),d.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(a)||d.isArray(a))&&(b=b.concat(j(a)))},this),b},a.prototype._compileSchema=function(a,c){if(c.__compiled)return b(c);c.__compiled=!0,this._fixInnerReferences(c),this._fixOuterReferences(c);var e=this._collectReferences(c),f=d.uniq(e.map(function(a){return a.$ref})),g=this;return b.all(f.map(function(b){return 0!==b.indexOf(c.$schema)?0===b.indexOf("http:")||0===b.indexOf("https:")?g._downloadRemoteReferences(a,c,b.split("#")[0]):void 0:void 0})).then(function(){return e.forEach(function(b){b.__$refResolved||(b.__$refResolved=d.resolveSchemaQuery(b,c,b.$ref,!0)||null),a.expect(null!=b.__$refResolved,"UNRESOLVABLE_REFERENCE",{ref:b.$ref})}),c})},a.prototype._fixInnerReferences=function k(a,b){b||(b=a),b.$ref&&null!==b.__$refResolved&&0!==b.$ref.indexOf("http:")&&0!==b.$ref.indexOf("https:")&&(b.__$refResolved=d.resolveSchemaQuery(b,a,b.$ref,!0)||null),d.forEach(b,function(b,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(b)||d.isArray(b))&&k(a,b)},this)},a.prototype._fixOuterReferences=function l(a,b){if(b=b||[],d.isString(a.id)&&b.push(a.id),a.$ref&&!a.__$refResolved&&b.length>0){var c=b.join("").split("#")[0];a.$ref="#"===a.$ref[0]?c+a.$ref:c.substring(0,1+c.lastIndexOf("/"))+a.$ref}d.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(a)||d.isArray(a))&&l(a,b)},this),d.isString(a.id)&&b.pop()},a.prototype._downloadRemoteReferences=function(a,c,e){var f=this,g=b.defer();return c.__remotes||(c.__remotes={}),c.id&&e===c.id.split("#")[0]?(c.__remotes[e]=c,g.resolve(),g.promise):(d.getRemoteSchema(e,function(b,d){return b?(b.description="Connection failed to: "+e,g.reject(b)):(g.resolve(f._compileSchema(a,d).then(function(a){c.__remotes[e]=a})),void 0)}),g.promise)},a.prototype._validateSchema=function(a,c){if(c.__validated)return b(c);c.__validated=!0;var e=this;return this.options.noTypeless===!0&&a.expect(void 0!==c.type,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"}),d.forEach(c,function(b,d){("string"!=typeof d||0!==d.indexOf("__"))&&(void 0!==h[d]?h[d].call(e,a,c):e.options.noExtraKeywords===!0?a.expect(!1,"KEYWORD_UNEXPECTED",{keyword:d}):a.addWarning('Unknown key "'+d+'" found in schema.'))}),a.toPromise()},a.prototype._validateObject=function(c,e,f){a.expect.object(e);var g=this,h=!1;c.rootSchema||(c.rootSchema=e,h=!0);for(var j=99;e.$ref&&j>0;)e=e.__$refResolved?e.__$refResolved:d.resolveSchemaQuery(e,c.rootSchema,e.$ref),j--;return b.all(d.map(e,function(a,d){return void 0!==i[d]?b.fcall(i[d].bind(g),c,e,f):void 0})).then(function(){return d.isArray(f)?g._recurseArray(c,e,f):d.isObject(f)?g._recurseObject(c,e,f):void 0}).then(function(){return h&&delete c.rootSchema,c})},a.prototype._recurseArray=function(a,c,e){var f=this,g=b();return d.isObject(c.items)?(e.forEach(function(b,d){g=g.then(function(){return a.goDown("["+d+"]"),f._validateObject(a,c.items,b).then(function(){a.goUp()})})}),g):d.isArray(c.items)?(e.forEach(function(b,e){g=g.then(function(){return e<c.items.length?(a.goDown("["+e+"]"),f._validateObject(a,c.items[e],b).then(function(){a.goUp()})):d.isObject(c.additionalItems)?(a.goDown("["+e+"]"),f._validateObject(a,c.additionalItems,b).then(function(){a.goUp()})):void 0})}),g):void 0},a.prototype._recurseObject=function(a,c,e){var f=this,g=b(),h=c.additionalProperties;(h===!0||void 0===h)&&(h={});var i=d.keys(c.properties||{}),j=d.keys(c.patternProperties||{});return d.forEach(e,function(b,e){var k=[];-1!==i.indexOf(e)&&k.push(c.properties[e]),j.forEach(function(a){d.getRegExp(a).test(e)===!0&&k.push(c.patternProperties[a])},this),0===k.length&&h!==!1&&k.push(h),k.forEach(function(c){g=g.then(function(){return a.goDown(e),f._validateObject(a,c,b).then(function(){a.goUp()})})})}),g};var h={$ref:function(a,b){a.expect(d.isString(b.$ref),"KEYWORD_TYPE_EXPECTED",{keyword:"$ref",type:"string"})},$schema:function(a,b){a.expect(d.isString(b.$schema),"KEYWORD_TYPE_EXPECTED",{keyword:"$schema",type:"string"})},multipleOf:function(a,b){var c=a.expect(d.isNumber(b.multipleOf),"KEYWORD_TYPE_EXPECTED",{keyword:"multipleOf",type:"number"});c&&a.expect(b.multipleOf>0,"KEYWORD_MUST_BE",{keyword:"multipleOf",expression:"strictly greater than 0"})},maximum:function(a,b){a.expect(d.isNumber(b.maximum),"KEYWORD_TYPE_EXPECTED",{keyword:"maximum",type:"number"})},exclusiveMaximum:function(a,b){var c=a.expect(d.isBoolean(b.exclusiveMaximum),"KEYWORD_TYPE_EXPECTED",{keyword:"exclusiveMaximum",type:"boolean"});c&&a.expect(void 0!==b.maximum,"KEYWORD_DEPENDENCY",{keyword1:"exclusiveMaximum",keyword2:"maximum"})},minimum:function(a,b){a.expect(d.isNumber(b.minimum),"KEYWORD_TYPE_EXPECTED",{keyword:"minimum",type:"number"})},exclusiveMinimum:function(a,b){var c=a.expect(d.isBoolean(b.exclusiveMinimum),"KEYWORD_TYPE_EXPECTED",{keyword:"exclusiveMinimum",type:"boolean"});c&&a.expect(void 0!==b.minimum,"KEYWORD_DEPENDENCY",{keyword1:"exclusiveMinimum",keyword2:"minimum"})},maxLength:function(a,b){var c=a.expect(d.isInteger(b.maxLength),"KEYWORD_TYPE_EXPECTED",{keyword:"maxLength",type:"integer"});c&&a.expect(b.maxLength>=0,"KEYWORD_MUST_BE",{keyword:"maxLength",expression:"greater than, or equal to 0"})},minLength:function(a,b){var c=a.expect(d.isInteger(b.minLength),"KEYWORD_TYPE_EXPECTED",{keyword:"minLength",type:"integer"});c&&a.expect(b.minLength>=0,"KEYWORD_MUST_BE",{keyword:"minLength",expression:"greater than, or equal to 0"})},pattern:function(a,b){var c=a.expect(d.isString(b.pattern),"KEYWORD_TYPE_EXPECTED",{keyword:"pattern",type:"string"});if(c)try{d.getRegExp(b.pattern)}catch(e){a.addError("KEYWORD_PATTERN",{keyword:"pattern",pattern:b.pattern})}},additionalItems:function(a,b){var c=d.isBoolean(b.additionalItems),e=d.isObject(b.additionalItems),f=a.expect(c||e,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalItems",type:["boolean","object"]});f&&e&&(a.goDown("additionalItems"),this._validateSchema(a,b.additionalItems),a.goUp())},items:function(a,b){var c=this,e=d.isArray(b.items),f=d.isObject(b.items),g=a.expect(e||f,"KEYWORD_TYPE_EXPECTED",{keyword:"items",type:["array","object"]});g&&(f?(a.goDown("items"),this._validateSchema(a,b.items),a.goUp()):e&&b.items.forEach(function(b,d){a.goDown("items["+d+"]"),c._validateSchema(a,b),a.goUp()}),c.options.forceAdditional===!0&&a.expect(void 0!==b.additionalItems,"KEYWORD_UNDEFINED_STRICT",{keyword:"additionalItems"}))},maxItems:function(a,b){var c=a.expect(d.isInteger(b.maxItems),"KEYWORD_TYPE_EXPECTED",{keyword:"maxItems",type:"integer"});c&&a.expect(b.maxItems>=0,"KEYWORD_MUST_BE",{keyword:"maxItems",expression:"greater than, or equal to 0"})},minItems:function(a,b){var c=a.expect(d.isInteger(b.minItems),"KEYWORD_TYPE_EXPECTED",{keyword:"minItems",type:"integer"});c&&a.expect(b.minItems>=0,"KEYWORD_MUST_BE",{keyword:"minItems",expression:"greater than, or equal to 0"})},uniqueItems:function(a,b){a.expect(d.isBoolean(b.uniqueItems),"KEYWORD_TYPE_EXPECTED",{keyword:"uniqueItems",type:"boolean"})},maxProperties:function(a,b){var c=a.expect(d.isInteger(b.maxProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"maxProperties",type:"integer"});c&&a.expect(b.maxProperties>=0,"KEYWORD_MUST_BE",{keyword:"maxProperties",expression:"greater than, or equal to 0"})},minProperties:function(a,b){var c=a.expect(d.isInteger(b.minProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"minProperties",type:"integer"});c&&a.expect(b.minProperties>=0,"KEYWORD_MUST_BE",{keyword:"minProperties",expression:"greater than, or equal to 0"})},required:function(a,b){var c;c=a.expect(d.isArray(b.required),"KEYWORD_TYPE_EXPECTED",{keyword:"required",type:"array"}),c&&(c=a.expect(b.required.length>0,"KEYWORD_MUST_BE",{keyword:"required",expression:"an array with at least one element"}),c&&(b.required.forEach(function(b){a.expect(d.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"required",type:"string"})},this),a.expect(d.isUniqueArray(b.required),"KEYWORD_MUST_BE",{keyword:"required",expression:"an array with unique items"})))},additionalProperties:function(a,b){var c=d.isBoolean(b.additionalProperties),e=d.isObject(b.additionalProperties),f=a.expect(c||e,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalProperties",type:["boolean","object"]});f&&e&&(a.goDown("additionalProperties"),this._validateSchema(a,b.additionalProperties),a.goUp())},properties:function(a,b){var c=this,e=a.expect(d.isObject(b.properties),"KEYWORD_TYPE_EXPECTED",{keyword:"properties",type:"object"});e&&(d.forEach(b.properties,function(b,d){a.goDown("properties["+d+"]"),c._validateSchema(a,b),a.goUp()}),c.options.forceAdditional===!0&&a.expect(void 0!==b.additionalProperties,"KEYWORD_UNDEFINED_STRICT",{keyword:"additionalProperties"}))},patternProperties:function(a,b){var c=this,e=a.expect(d.isObject(b.patternProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"patternProperties",type:"object"});e&&d.forEach(b.patternProperties,function(b,e){try{d.getRegExp(e)}catch(f){a.addError("KEYWORD_PATTERN",{keyword:"patternProperties",pattern:e})}a.goDown("patternProperties["+e+"]"),c._validateSchema(a,b),a.goUp()})},dependencies:function(a,b){var c=this,e=a.expect(d.isObject(b.dependencies),"KEYWORD_TYPE_EXPECTED","dependencies","object");e&&d.forEach(b.dependencies,function(b,e){var f=d.isObject(b),g=d.isArray(b);a.expect(f||g,"KEYWORD_VALUE_TYPE",{keyword:"dependencies",type:"object or array"}),f?(a.goDown("dependencies["+e+"]"),c._validateSchema(a,b),a.goUp()):g&&(a.expect(b.length>0,"KEYWORD_MUST_BE",{keyword:"dependencies",expression:"not empty array"}),b.forEach(function(b){a.expect(d.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"dependensices",type:"string"})}),a.expect(d.isUniqueArray(b),{keyword:"dependencies",expression:"an array with unique items"}))})},"enum":function(a,b){var c;c=a.expect(d.isArray(b.enum),"KEYWORD_TYPE_EXPECTED",{keyword:"enum",type:"array"}),c&&(c=a.expect(b.enum.length>0,"KEYWORD_MUST_BE",{keyword:"enum",expression:"an array with at least one element"}),c&&(c=a.expect(d.isUniqueArray(b.enum),"KEYWORD_MUST_BE",{keyword:"enum",expression:"an array with unique items"})))},type:function(a,b){var c,e=["array","boolean","integer","number","null","object","string"],f=e.join(","),g=d.isString(b.type),h=d.isArray(b.type);c=a.expect(g||h,"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:["string","array"]}),c&&(h?(b.type.forEach(function(b){a.expect(-1!==e.indexOf(b),"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:f})},this),a.expect(d.isUniqueArray(b.type),"KEYWORD_MUST_BE",{keyword:"type",expression:"an object with unique properties"})):a.expect(-1!==e.indexOf(b.type),"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:f}),this.options.noZeroLengthStrings===!0&&("string"===b.type||h&&-1!==b.type.indexOf("string"))&&void 0===b.minLength&&(b.minLength=1),this.options.forceProperties===!0&&("object"===b.type||h&&-1!==b.type.indexOf("object"))&&a.expect(void 0!==b.properties||void 0!==b.patternProperties,"KEYWORD_UNDEFINED_STRICT",{keyword:"properties"}),this.options.forceItems===!0&&("array"===b.type||h&&-1!==b.type.indexOf("array"))&&a.expect(void 0!==b.items,"KEYWORD_UNDEFINED_STRICT",{keyword:"items"}),this.options.forceMaxLength===!0&&("string"===b.type||h&&-1!==b.type.indexOf("string"))&&a.expect(void 0!==b.maxLength||void 0!==b.format||void 0!==b.enum,"KEYWORD_UNDEFINED_STRICT",{keyword:"maxLength"}))},allOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.allOf),"KEYWORD_TYPE_EXPECTED",{keyword:"allOf",type:"array"}),c&&(c=a.expect(b.allOf.length>0,"KEYWORD_MUST_BE",{keyword:"allOf",expression:"an array with at least one element"}),c&&b.allOf.forEach(function(b,c){a.goDown("allOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},anyOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.anyOf),"KEYWORD_TYPE_EXPECTED",{keyword:"anyOf",type:"array"}),c&&(c=a.expect(b.anyOf.length>0,"KEYWORD_MUST_BE",{keyword:"anyOf",expression:"an array with at least one element"}),c&&b.anyOf.forEach(function(b,c){a.goDown("anyOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},oneOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.oneOf),"KEYWORD_TYPE_EXPECTED",{keyword:"oneOf",type:"array"}),c&&(c=a.expect(b.oneOf.length>0,"KEYWORD_MUST_BE",{keyword:"oneOf",expression:"an array with at least one element"}),c&&b.oneOf.forEach(function(b,c){a.goDown("oneOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},not:function(a,b){var c;c=a.expect(d.isObject(b.not),"KEYWORD_TYPE_EXPECTED",{keyword:"not",type:"object"}),c&&(a.goDown("not"),this._validateSchema(a,b.not),a.goUp())},definitions:function(a,b){var c,e=this;c=a.expect(d.isObject(b.definitions),"KEYWORD_TYPE_EXPECTED",{keyword:"definitions",type:"object"}),c&&d.forEach(b.definitions,function(b,c){a.goDown("definitions["+c+"]"),e._validateSchema(a,b),a.goUp()})},format:function(a,b){var c;c=a.expect(d.isString(b.format),"KEYWORD_TYPE_EXPECTED",{keyword:"format",type:"string"}),c&&(c=a.expect(d.isFunction(e[b.format])||d.isFunction(f[b.format]),"UNKNOWN_FORMAT",{format:b.format}))},id:function(a,b){a.expect(d.isString(b.id),"KEYWORD_TYPE_EXPECTED",{keyword:"id",type:"string"})},title:function(a,b){a.expect(d.isString(b.title),"KEYWORD_TYPE_EXPECTED",{keyword:"title",type:"string"})},description:function(a,b){a.expect(d.isString(b.description),"KEYWORD_TYPE_EXPECTED",{keyword:"description",type:"string"})},"default":function(){},__compiled:function(b,c){a.expect.boolean(c.__compiled)},__validated:function(b,c){a.expect.boolean(c.__validated)}},i={multipleOf:function(a,b,c){if(d.isNumber(c)){var e="integer"===d.whatIs(c/b.multipleOf);a.expect(e,"MULTIPLE_OF",{value:c,multipleOf:b.multipleOf})}},maximum:function(a,b,c){d.isNumber(c)&&(b.exclusiveMaximum!==!0?a.expect(c<=b.maximum,"MAXIMUM",{value:c,maximum:b.maximum}):a.expect(c<b.maximum,"MAXIMUM_EXCLUSIVE",{value:c,maximum:b.maximum}))},exclusiveMaximum:function(){},minimum:function(a,b,c){d.isNumber(c)&&(b.exclusiveMinimum!==!0?a.expect(c>=b.minimum,"MINIMUM",{value:c,minimum:b.minimum}):a.expect(c>b.minimum,"MINIMUM_EXCLUSIVE",{value:c,minimum:b.minimum}))},exclusiveMinimum:function(){},maxLength:function(a,b,c){d.isString(c)&&a.expect(c.length<=b.maxLength,"MAX_LENGTH",{length:c.length,maximum:b.maxLength})},minLength:function(a,b,c){d.isString(c)&&a.expect(c.length>=b.minLength,"MIN_LENGTH",{length:c.length,minimum:b.minLength})},pattern:function(a,b,c){d.isString(c)&&a.expect(d.getRegExp(b.pattern).test(c),"PATTERN",{pattern:b.pattern})},additionalItems:function(a,b,c){d.isArray(c)&&b.additionalItems===!1&&d.isArray(b.items)&&a.expect(c.length<=b.items.length,"ARRAY_ADDITIONAL_ITEMS")},items:function(){},maxItems:function(a,b,c){d.isArray(c)&&a.expect(c.length<=b.maxItems,"ARRAY_LENGTH_LONG",{length:c.length,maximum:b.maxItems})},minItems:function(a,b,c){d.isArray(c)&&a.expect(c.length>=b.minItems,"ARRAY_LENGTH_SHORT",{length:c.length,minimum:b.minItems})},uniqueItems:function(a,b,c){if(d.isArray(c)&&b.uniqueItems===!0){var e={};a.expect(d.isUniqueArray(c,e),"ARRAY_UNIQUE",e)}},maxProperties:function(a,b,c){d.isObject(c)&&a.expect(d.keys(c).length<=b.maxProperties,"OBJECT_PROPERTIES_MAXIMUM",{count:d.keys(c).length,maximum:b.maxProperties})},minProperties:function(a,b,c){d.isObject(c)&&a.expect(d.keys(c).length>=b.minProperties,"OBJECT_PROPERTIES_MINIMUM",{count:d.keys(c).length,minimum:b.maxProperties})},required:function(a,b,c){d.isObject(c)&&b.required.forEach(function(b){a.expect(void 0!==c[b],"OBJECT_REQUIRED",{property:b})})},additionalProperties:function(a,b){return void 0===b.properties&&void 0===b.patternProperties?i.properties.apply(this,arguments):void 0},properties:function(a,b,c){if(d.isObject(c)){var e=void 0!==b.properties?b.properties:{},f=void 0!==b.patternProperties?b.patternProperties:{};if(b.additionalProperties===!1){var g=d.keys(c),h=d.keys(e),i=d.keys(f);g=d.difference(g,h),i.forEach(function(a){for(var b=d.getRegExp(a),c=g.length-1;c>=0;c--)b.test(g[c])===!0&&g.splice(c,1)},this),a.expect(0===g.length,"OBJECT_ADDITIONAL_PROPERTIES",{properties:g})}}},patternProperties:function(a,b){return void 0===b.properties?i.properties.apply(this,arguments):void 0},dependencies:function(a,c,e){var f=this,g=b();return d.isObject(e)?(d.forEach(c.dependencies,function(b,c){g=g.then(function(){if(void 0!==e[c]){if(d.isObject(b))return f._validateObject(a,b,e);d.forEach(b,function(b){a.expect(void 0!==e[b],"OBJECT_DEPENDENCY_KEY",{missing:b,key:c})})}})}),g):void 0},"enum":function(a,b,c){for(var e=!1,f=0,g=b.enum.length;g>f;f++)if(d.areEqual(c,b.enum[f])){e=!0;break}a.expect(e,"ENUM_MISMATCH",{value:c})},type:function(a,b,c){var e=d.whatIs(c);if(d.isString(b.type))a.expect(e===b.type||"integer"===e&&"number"===b.type,"INVALID_TYPE",{expected:b.type,type:e});else{var f=-1!==b.type.indexOf(e),g="integer"===e&&-1!==b.type.indexOf("number");a.expect(f||g,"INVALID_TYPE",{expected:b.type,type:e})}},allOf:function(a,c,d){var e=this,f=b();return c.allOf.forEach(function(b){f=f.then(function(){return e._validateObject(a,b,d)})}),f},anyOf:function(a,c,d){var e=0,f=[],h=this,i=b();return c.anyOf.forEach(function(b){i=i.then(function(){if(!(e>0)){var c=new g(a);return h._validateObject(c,b,d).then(function(){c.isValid()?e++:f.push(c)})}})}),i.then(function(){a.expect(e>=1,"ANY_OF_MISSING",{},0===e?f:null)})},oneOf:function(a,c,d){var e=this,f=0,h=[],i=b();return c.oneOf.forEach(function(b){i=i.then(function(){var c=new g(a);return e._validateObject(c,b,d).then(function(){c.isValid()?f++:h.push(c)})})}),i.then(function(){a.expect(f>0,"ONE_OF_MISSING",{},0===f?h:null),a.expect(2>f,"ONE_OF_MULTIPLE")})},not:function(a,b,c){var d=new g(a);return this._validateObject(d,b.not,c).then(function(){a.expect(!d.isValid(),"NOT_PASSED")})},definitions:function(){},format:function(a,c,g){if("function"==typeof e[c.format])return a.expect(e[c.format](g),"FORMAT",{format:c.format,error:g}),void 0;var h=b.defer();try{var i=f[c.format](g,h.makeNodeResolver());(b.isPromise(i)||d.isBoolean(i))&&h.resolve(i)}catch(j){h.reject(j)}return h.promise.then(function(b){b||a.addError("FORMAT",{format:c.format})}).fail(function(b){a.addError("FORMAT",{format:c.format,error:b})})}};module.exports=a}();
/*! z-schema version 2.1.0 */
!function(){"use strict";function a(a){this.options=d.defaults(a||{},{noExtraKeywords:!1,noZeroLengthStrings:!1,noTypeless:!1,forceAdditional:!1,forceProperties:!1,forceItems:!1,forceMaxLength:!1,noSchemaCache:!1}),this.options.strict===!0&&(this.options.noExtraKeywords=!0,this.options.noZeroLengthStrings=!0,this.options.noTypeless=!0,this.options.forceAdditional=!0,this.options.forceProperties=!0,this.options.forceItems=!0,this.options.forceMaxLength=!0),this.options.noSchemaCache!==!0&&(this.schemaCache={})}var b=require("q"),c=function(a,b,c,d){this.code=a,this.message=b,this.path=d||"",this.params=c||{}};c.prototype=new Error,c.messages={INVALID_TYPE:"invalid type: {type} (expected {expected})",ENUM_MISMATCH:"No enum match for: {value}",ANY_OF_MISSING:'Data does not match any schemas from "anyOf"',ONE_OF_MISSING:'Data does not match any schemas from "oneOf"',ONE_OF_MULTIPLE:'Data is valid against more than one schema from "oneOf"',NOT_PASSED:'Data matches schema from "not"',UNRESOLVABLE_REFERENCE:"Reference could not be resolved: {ref}",MULTIPLE_OF:"Value {value} is not a multiple of {multipleOf}",MINIMUM:"Value {value} is less than minimum {minimum}",MINIMUM_EXCLUSIVE:"Value {value} is equal or less than exclusive minimum {minimum}",MAXIMUM:"Value {value} is greater than maximum {maximum}",MAXIMUM_EXCLUSIVE:"Value {value} is equal or greater than exclusive maximum {maximum}",MIN_LENGTH:"String is too short ({length} chars), minimum {minimum}",MAX_LENGTH:"String is too long ({length} chars), maximum {maximum}",PATTERN:"String does not match pattern: {pattern}",OBJECT_PROPERTIES_MINIMUM:"Too few properties defined ({count}), minimum {minimum}",OBJECT_PROPERTIES_MAXIMUM:"Too many properties defined ({count}), maximum {maximum}",OBJECT_REQUIRED:"Missing required property: {property}",OBJECT_ADDITIONAL_PROPERTIES:"Additional properties not allowed",OBJECT_DEPENDENCY_KEY:"Dependency failed - key must exist: {missing} (due to key: {key})",ARRAY_LENGTH_SHORT:"Array is too short ({length}), minimum {minimum}",ARRAY_LENGTH_LONG:"Array is too long ({length}), maximum {maximum}",ARRAY_UNIQUE:"Array items are not unique (indices {index1} and {index2})",ARRAY_ADDITIONAL_ITEMS:"Additional items not allowed",FORMAT:"{format} format validation failed: {error}",KEYWORD_TYPE_EXPECTED:'Keyword "{keyword}" is expected to be type of type "{type}"',KEYWORD_UNDEFINED_STRICT:'Keyword "{keyword}" must be defined in strict mode',KEYWORD_UNEXPECTED:'Keyword "{keyword}" is not expected to appear in the schema',KEYWORD_MUST_BE:'Keyword "{keyword}" must be {expression}',KEYWORD_DEPENDENCY:'Keyword "{keyword1}" requires keyword "{keyword2}"',KEYWORD_PATTERN:'Keyword "{keyword}" is not a valid RegExp pattern ({pattern})',KEYWORD_VALUE_TYPE:'Each element of keyword "{keyword}" array must be a "{type}"',UNKNOWN_FORMAT:'There is no validation function for format "{format}"'},c.prototype.addSubError=function(a){this.subErrors||(this.subErrors=[]),this.subErrors.push(a)},c.createError=function(a,b,d){var e=c.messages[a];if(b=b||{},"string"!=typeof e)throw new Error("Unknown error code: "+a);return e=e.replace(/\{([^{}]*)\}/g,function(a,c){var d=b[c];return"string"==typeof d||"number"==typeof d?d:d&&"function"==typeof d.toString?d.toString():a}),new c(a,e,b,d)};var d={isBoolean:function(a){return"boolean"==typeof a},isString:function(a){return"string"==typeof a},isInteger:function(a){return this.isNumber(a)&&0===a%1},isNumber:function(a){return"number"==typeof a&&Number.isFinite(a)},isArray:function(a){return Array.isArray(a)},isObject:function(a){return"object"==typeof a&&a===Object(a)&&!Array.isArray(a)},isFunction:function(a){return"function"==typeof a},whatIs:function(a){if(void 0===a)return"undefined";if(null===a)return"null";if(this.isBoolean(a))return"boolean";if(this.isString(a))return"string";if(this.isArray(a))return"array";if(this.isInteger(a))return"integer";if(this.isNumber(a))return"number";if(this.isObject(a))return"object";if(this.isFunction(a))return"function";if(Number.isNaN(a))return"not-a-number";throw new Error("Utils.whatIs does not know what this is: "+a)},isUniqueArray:function(a,b){b=b||{};var c,d,e=a.length;for(c=0;e>c;c++)for(d=c+1;e>d;d++)if(this.areEqual(a[c],a[d]))return b.index1=c,b.index2=d,!1;return!0},keys:function(a){var b,c=[];for(b in a)a.hasOwnProperty(b)&&c.push(b);return c},forEach:function(a,b,c){if(Array.isArray(a))return a.forEach(b,c);if(d.isObject(a)){var e;for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e)}},map:function(a,b,c){var e=-1,f=[];return d.forEach(a,function(a,d){f[++e]=b.call(c,a,d)}),f},defaults:function(a,b){return d.forEach(b,function(b,c){void 0===a[c]&&(a[c]=b)}),a},uniq:function(a){var b=[];return a.forEach(function(a){-1===b.indexOf(a)&&b.push(a)}),b},difference:function(a,b){var c=[];return a.forEach(function(a){-1===b.indexOf(a)&&c.push(a)}),c},areEqual:function(a,b){if(a===b)return!0;var c,d;if(this.isArray(a)&&this.isArray(b)){if(a.length!==b.length)return!1;for(d=a.length,c=0;d>c;c++)if(!this.areEqual(a[c],b[c]))return!1;return!0}if(this.isObject(a)&&this.isObject(b)){var e=this.keys(a),f=this.keys(b);if(!this.areEqual(e,f))return!1;for(d=e.length,c=0;d>c;c++)if(!this.areEqual(a[e[c]],b[e[c]]))return!1;return!0}return!1},decodeJSONPointer:function(a){return decodeURIComponent(a).replace(/~[0-1]/g,function(a){return"~1"===a?"/":"~"})},_getRegExpCache:{},getRegExp:function(a){return this._getRegExpCache[a]||(this._getRegExpCache[a]=new RegExp(a)),this._getRegExpCache[a]},_getRemoteSchemaCache:{},getRemoteSchema:function(a,b){function c(a){var c=JSON.parse(a);c.id||(c.id=d),c.$schema||(c.$schema=d),b(void 0,c)}var d=a.split("#")[0];if(this._getRemoteSchemaCache[d])return c(this._getRemoteSchemaCache[d]),void 0;var e=this,f=require("http");f.get(d,function(a){var b="";a.on("data",function(a){b+=a}),a.on("end",function(){c(e._getRemoteSchemaCache[d]=b)})}).on("error",function(a){b(a)})},resolveSchemaQuery:function(b,c,e,f){if(a.expect.string(e),"#"===e)return c;var g=null,h=e.split("#")[0],i=e.split("#")[1];if(h)if(0===h.indexOf("http:")||0===h.indexOf("https:")){if(!c.__remotes||!c.__remotes[h])throw new Error("Remote is not downloaded: "+h);g=c.__remotes[h]}else g=d.resolveSchemaId(c,h);else g=c;if(g&&i)for(var j=("#"+i).split("/");j.length>0;){var k=d.decodeJSONPointer(j.shift());-1===k.indexOf("#")?g=g[k]:"#"!==k&&(g=d.resolveSchemaId(g,k))}if(!g&&!f)throw new Error("Could not resolve schema reference: "+e);return g},resolveSchemaId:function(a,b){if(this.isObject(a)||this.isArray(a)){if(a.id===b)return a;var c=null;return d.forEach(a,function(a){c||(c=d.resolveSchemaId(a,b))}),c}}},e={date:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$").exec(a);if(null===b)return!1;var c=b[2],e=b[3];return"01">c||c>"12"||"01">e||e>"31"?!1:!0},"date-time":function(a){if(!d.isString(a))return!0;var b=a.toLowerCase().split("t");if(!e.date(b[0]))return!1;var c=d.getRegExp("^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$").exec(b[1]);if(null===c)return!1;var f=c[1],g=c[2],h=c[3];return f>"23"||g>"59"||h>"59"?!1:!0},email:function(a){if(!d.isString(a))return!0;var b=d.getRegExp(/^[-a-z0-9~!$%^&*_=+}{\'?]+(\.[-a-z0-9~!$%^&*_=+}{\'?]+)*@([a-z0-9_][-a-z0-9_]*(\.[-a-z0-9_]+)*\.(aero|arpa|biz|com|coop|edu|gov|info|int|mil|museum|name|net|org|pro|travel|mobi|[a-z][a-z])|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,5})?$/i);return b.test(a)},hostname:function(a){if(!d.isString(a))return!0;if(-1===a.indexOf("."))return!1;var b=d.getRegExp("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$");return b.test(a)},"host-name":function(){return e.hostname.apply(this,arguments)},ipv4:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");return b.test(a)},ipv6:function(a){if(!d.isString(a))return!0;var b=d.getRegExp("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$");return b.test(a)},uri:function(a){if(!d.isString(a))return!0;var b=new RegExp("^(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!10(?:\\.\\d{1,3}){3})(?!127(?:\\.\\d{1,3}){3})(?!169\\.254(?:\\.\\d{1,3}){2})(?!192\\.168(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))(?::\\d{2,5})?(?:/[^\\s]*)?$","i");return b.test(a)}},f={},g=function(a){a&&(this.parentReport=a,d.forEach(a,function(a,b){this[b]=a},this)),this.errors=[],this.warnings=[],this.path=[]};g.prototype={getPath:function(){var a=["#"];return this.parentReport&&(a=a.concat(this.parentReport.path)),a=a.concat(this.path),1==a.length?"#/":a.join("/")},addWarning:function(a){return this.warnings.push({message:a,path:this.getPath()}),!0},addError:function(a,b,d){var e=c.createError(a,b,this.getPath());return d&&d.forEach(function(a){a.errors.forEach(function(a){e.addSubError(a)},this)},this),this.errors.push(e),!1},expect:function(a,b,c,d){return a?!0:(this.addError(b,c,d),!1)},isValid:function(){return 0===this.errors.length},toJSON:function(){return{valid:0===this.errors.length,errors:this.errors,warnings:this.warnings}},toError:function(){var a=new Error("Validation failed");return a.errors=this.errors,a.warnings=this.warnings,a},toPromise:function(){return this.isValid()?b(this):b.reject(this.toError())},goDown:function(a){this.path.push(a)},goUp:function(){this.path.pop()}},a.expect={typeError:function(a,b){return'Type mismatch, expected "'+a+'", got "'+d.whatIs(b)+'"'},"boolean":function(b){if(!d.isBoolean(b))throw new Error(a.expect.typeError("boolean",b))},string:function(b){if(!d.isString(b))throw new Error(a.expect.typeError("string",b))},callable:function(b){if(!d.isFunction(b))throw new Error(a.expect.typeError("function",b))},object:function(b){if(!d.isObject(b))throw new Error(a.expect.typeError("object",b))}},a.validate=function(){if(!this._defaultInstance){var a=this;this._defaultInstance=new a}return this._defaultInstance.validate.apply(this._defaultInstance,arguments)},a.registerFormat=function(b,c){if(a.expect.string(b),a.expect.callable(c),e[b])throw new Error("Cannot override built-in validator for "+b);if(f[b])throw new Error("Cannot override existing validator for "+b);f[b]=c},a.setRemoteReference=function(b,c){a.expect.string(c),d._getRemoteSchemaCache[b]=c},a.prototype.validate=function(a,b,c){var d=this,e=new g;return this._compileSchema(e,b).then(function(b){return d._validateSchema(e,b).then(function(){return d._validateObject(e,b,a).then(function(){return e.toPromise()})})}).then(function(){return e.toJSON()}).nodeify(c)},a.prototype.compileSchema=function(a,c){var d=this;if(Array.isArray(a)){var e=b();return a.forEach(function(a){e=e.then(function(){return d.compileSchema.call(d,a)})}),e.nodeify(c)}var f=new g;return this._compileSchema(f,a).then(function(a){return d._validateSchema(f,a).then(function(){return a})}).nodeify(c)},a.prototype.validateSchema=function(a,b){var c=new g;return this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},a.prototype._collectReferences=function j(a){var b=[];return a.$ref&&b.push(a),d.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(a)||d.isArray(a))&&(b=b.concat(j(a)))},this),b},a.prototype._compileSchema=function(a,c){if(c.__$compiled)return b(c);this._fixInnerReferences(c),this._fixOuterReferences(c);var e=this._collectReferences(c),f=d.uniq(e.map(function(a){return a.$ref})),g=this;return b.all(f.map(function(b){return 0!==b.indexOf(c.$schema)?0===b.indexOf("http:")||0===b.indexOf("https:")?g._downloadRemoteReferences(a,c,b.split("#")[0]):void 0:void 0})).then(function(){return e.forEach(function(b){b.__$refResolved||(b.__$refResolved=d.resolveSchemaQuery(b,c,b.$ref,!0)||null),g.schemaCache&&g.schemaCache[b.$ref]&&(b.__$refResolved=g.schemaCache[b.$ref]),a.expect(null!=b.__$refResolved,"UNRESOLVABLE_REFERENCE",{ref:b.$ref})}),a.isValid()&&(c.__$compiled=!0),c.id&&g.schemaCache&&(g.schemaCache[c.id]=c),c})},a.prototype._fixInnerReferences=function k(a,b){b||(b=a),b.$ref&&null!==b.__$refResolved&&0!==b.$ref.indexOf("http:")&&0!==b.$ref.indexOf("https:")&&(b.__$refResolved=d.resolveSchemaQuery(b,a,b.$ref,!0)||null),d.forEach(b,function(b,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(b)||d.isArray(b))&&k(a,b)},this)},a.prototype._fixOuterReferences=function l(a,b){if(b=b||[],d.isString(a.id)&&b.push(a.id),a.$ref&&!a.__$refResolved&&b.length>0){var c=b.join("").split("#")[0];a.$ref="#"===a.$ref[0]?c+a.$ref:c.substring(0,1+c.lastIndexOf("/"))+a.$ref}d.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(d.isObject(a)||d.isArray(a))&&l(a,b)},this),d.isString(a.id)&&b.pop()},a.prototype._downloadRemoteReferences=function(a,c,e){var f=this,g=b.defer();return c.__remotes||(c.__remotes={}),c.id&&e===c.id.split("#")[0]?(c.__remotes[e]=c,g.resolve(),g.promise):(d.getRemoteSchema(e,function(b,d){return b?(b.description="Connection failed to: "+e,g.reject(b)):(g.resolve(f._compileSchema(a,d).then(function(a){c.__remotes[e]=a})),void 0)}),g.promise)},a.prototype._validateSchema=function(a,c){if(c.__$validated)return b(c);var e=this;return this.options.noTypeless===!0&&a.expect(void 0!==c.type,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"}),d.forEach(c,function(b,d){("string"!=typeof d||0!==d.indexOf("__"))&&(void 0!==h[d]?h[d].call(e,a,c):e.options.noExtraKeywords===!0?a.expect(!1,"KEYWORD_UNEXPECTED",{keyword:d}):a.addWarning('Unknown key "'+d+'" found in schema.'))}),a.isValid()&&(c.__$validated=!0),a.toPromise()},a.prototype._validateObject=function(c,e,f){a.expect.object(e);var g=this,h=!1;c.rootSchema||(c.rootSchema=e,h=!0);for(var j=99;e.$ref&&j>0;)e=e.__$refResolved?e.__$refResolved:d.resolveSchemaQuery(e,c.rootSchema,e.$ref),j--;return b.all(d.map(e,function(a,d){return void 0!==i[d]?b.fcall(i[d].bind(g),c,e,f):void 0})).then(function(){return d.isArray(f)?g._recurseArray(c,e,f):d.isObject(f)?g._recurseObject(c,e,f):void 0}).then(function(){return h&&delete c.rootSchema,c})},a.prototype._recurseArray=function(a,c,e){var f=this,g=b();return d.isObject(c.items)?(e.forEach(function(b,d){g=g.then(function(){return a.goDown("["+d+"]"),f._validateObject(a,c.items,b).then(function(){a.goUp()})})}),g):d.isArray(c.items)?(e.forEach(function(b,e){g=g.then(function(){return e<c.items.length?(a.goDown("["+e+"]"),f._validateObject(a,c.items[e],b).then(function(){a.goUp()})):d.isObject(c.additionalItems)?(a.goDown("["+e+"]"),f._validateObject(a,c.additionalItems,b).then(function(){a.goUp()})):void 0})}),g):void 0},a.prototype._recurseObject=function(a,c,e){var f=this,g=b(),h=c.additionalProperties;(h===!0||void 0===h)&&(h={});var i=d.keys(c.properties||{}),j=d.keys(c.patternProperties||{});return d.forEach(e,function(b,e){var k=[];-1!==i.indexOf(e)&&k.push(c.properties[e]),j.forEach(function(a){d.getRegExp(a).test(e)===!0&&k.push(c.patternProperties[a])},this),0===k.length&&h!==!1&&k.push(h),k.forEach(function(c){g=g.then(function(){return a.goDown(e),f._validateObject(a,c,b).then(function(){a.goUp()})})})}),g};var h={$ref:function(a,b){a.expect(d.isString(b.$ref),"KEYWORD_TYPE_EXPECTED",{keyword:"$ref",type:"string"})},$schema:function(a,b){a.expect(d.isString(b.$schema),"KEYWORD_TYPE_EXPECTED",{keyword:"$schema",type:"string"})},multipleOf:function(a,b){var c=a.expect(d.isNumber(b.multipleOf),"KEYWORD_TYPE_EXPECTED",{keyword:"multipleOf",type:"number"});c&&a.expect(b.multipleOf>0,"KEYWORD_MUST_BE",{keyword:"multipleOf",expression:"strictly greater than 0"})},maximum:function(a,b){a.expect(d.isNumber(b.maximum),"KEYWORD_TYPE_EXPECTED",{keyword:"maximum",type:"number"})},exclusiveMaximum:function(a,b){var c=a.expect(d.isBoolean(b.exclusiveMaximum),"KEYWORD_TYPE_EXPECTED",{keyword:"exclusiveMaximum",type:"boolean"});c&&a.expect(void 0!==b.maximum,"KEYWORD_DEPENDENCY",{keyword1:"exclusiveMaximum",keyword2:"maximum"})},minimum:function(a,b){a.expect(d.isNumber(b.minimum),"KEYWORD_TYPE_EXPECTED",{keyword:"minimum",type:"number"})},exclusiveMinimum:function(a,b){var c=a.expect(d.isBoolean(b.exclusiveMinimum),"KEYWORD_TYPE_EXPECTED",{keyword:"exclusiveMinimum",type:"boolean"});c&&a.expect(void 0!==b.minimum,"KEYWORD_DEPENDENCY",{keyword1:"exclusiveMinimum",keyword2:"minimum"})},maxLength:function(a,b){var c=a.expect(d.isInteger(b.maxLength),"KEYWORD_TYPE_EXPECTED",{keyword:"maxLength",type:"integer"});c&&a.expect(b.maxLength>=0,"KEYWORD_MUST_BE",{keyword:"maxLength",expression:"greater than, or equal to 0"})},minLength:function(a,b){var c=a.expect(d.isInteger(b.minLength),"KEYWORD_TYPE_EXPECTED",{keyword:"minLength",type:"integer"});c&&a.expect(b.minLength>=0,"KEYWORD_MUST_BE",{keyword:"minLength",expression:"greater than, or equal to 0"})},pattern:function(a,b){var c=a.expect(d.isString(b.pattern),"KEYWORD_TYPE_EXPECTED",{keyword:"pattern",type:"string"});if(c)try{d.getRegExp(b.pattern)}catch(e){a.addError("KEYWORD_PATTERN",{keyword:"pattern",pattern:b.pattern})}},additionalItems:function(a,b){var c=d.isBoolean(b.additionalItems),e=d.isObject(b.additionalItems),f=a.expect(c||e,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalItems",type:["boolean","object"]});f&&e&&(a.goDown("additionalItems"),this._validateSchema(a,b.additionalItems),a.goUp())},items:function(a,b){var c=this,e=d.isArray(b.items),f=d.isObject(b.items),g=a.expect(e||f,"KEYWORD_TYPE_EXPECTED",{keyword:"items",type:["array","object"]});g&&(f?(a.goDown("items"),this._validateSchema(a,b.items),a.goUp()):e&&b.items.forEach(function(b,d){a.goDown("items["+d+"]"),c._validateSchema(a,b),a.goUp()}),c.options.forceAdditional===!0&&a.expect(void 0!==b.additionalItems,"KEYWORD_UNDEFINED_STRICT",{keyword:"additionalItems"}))},maxItems:function(a,b){var c=a.expect(d.isInteger(b.maxItems),"KEYWORD_TYPE_EXPECTED",{keyword:"maxItems",type:"integer"});c&&a.expect(b.maxItems>=0,"KEYWORD_MUST_BE",{keyword:"maxItems",expression:"greater than, or equal to 0"})},minItems:function(a,b){var c=a.expect(d.isInteger(b.minItems),"KEYWORD_TYPE_EXPECTED",{keyword:"minItems",type:"integer"});c&&a.expect(b.minItems>=0,"KEYWORD_MUST_BE",{keyword:"minItems",expression:"greater than, or equal to 0"})},uniqueItems:function(a,b){a.expect(d.isBoolean(b.uniqueItems),"KEYWORD_TYPE_EXPECTED",{keyword:"uniqueItems",type:"boolean"})},maxProperties:function(a,b){var c=a.expect(d.isInteger(b.maxProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"maxProperties",type:"integer"});c&&a.expect(b.maxProperties>=0,"KEYWORD_MUST_BE",{keyword:"maxProperties",expression:"greater than, or equal to 0"})},minProperties:function(a,b){var c=a.expect(d.isInteger(b.minProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"minProperties",type:"integer"});c&&a.expect(b.minProperties>=0,"KEYWORD_MUST_BE",{keyword:"minProperties",expression:"greater than, or equal to 0"})},required:function(a,b){var c;c=a.expect(d.isArray(b.required),"KEYWORD_TYPE_EXPECTED",{keyword:"required",type:"array"}),c&&(c=a.expect(b.required.length>0,"KEYWORD_MUST_BE",{keyword:"required",expression:"an array with at least one element"}),c&&(b.required.forEach(function(b){a.expect(d.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"required",type:"string"})},this),a.expect(d.isUniqueArray(b.required),"KEYWORD_MUST_BE",{keyword:"required",expression:"an array with unique items"})))},additionalProperties:function(a,b){var c=d.isBoolean(b.additionalProperties),e=d.isObject(b.additionalProperties),f=a.expect(c||e,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalProperties",type:["boolean","object"]});f&&e&&(a.goDown("additionalProperties"),this._validateSchema(a,b.additionalProperties),a.goUp())},properties:function(a,b){var c=this,e=a.expect(d.isObject(b.properties),"KEYWORD_TYPE_EXPECTED",{keyword:"properties",type:"object"});e&&(d.forEach(b.properties,function(b,d){a.goDown("properties["+d+"]"),c._validateSchema(a,b),a.goUp()}),c.options.forceAdditional===!0&&a.expect(void 0!==b.additionalProperties,"KEYWORD_UNDEFINED_STRICT",{keyword:"additionalProperties"}))},patternProperties:function(a,b){var c=this,e=a.expect(d.isObject(b.patternProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"patternProperties",type:"object"});e&&d.forEach(b.patternProperties,function(b,e){try{d.getRegExp(e)}catch(f){a.addError("KEYWORD_PATTERN",{keyword:"patternProperties",pattern:e})}a.goDown("patternProperties["+e+"]"),c._validateSchema(a,b),a.goUp()})},dependencies:function(a,b){var c=this,e=a.expect(d.isObject(b.dependencies),"KEYWORD_TYPE_EXPECTED","dependencies","object");e&&d.forEach(b.dependencies,function(b,e){var f=d.isObject(b),g=d.isArray(b);a.expect(f||g,"KEYWORD_VALUE_TYPE",{keyword:"dependencies",type:"object or array"}),f?(a.goDown("dependencies["+e+"]"),c._validateSchema(a,b),a.goUp()):g&&(a.expect(b.length>0,"KEYWORD_MUST_BE",{keyword:"dependencies",expression:"not empty array"}),b.forEach(function(b){a.expect(d.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"dependensices",type:"string"})}),a.expect(d.isUniqueArray(b),{keyword:"dependencies",expression:"an array with unique items"}))})},"enum":function(a,b){var c;c=a.expect(d.isArray(b.enum),"KEYWORD_TYPE_EXPECTED",{keyword:"enum",type:"array"}),c&&(c=a.expect(b.enum.length>0,"KEYWORD_MUST_BE",{keyword:"enum",expression:"an array with at least one element"}),c&&(c=a.expect(d.isUniqueArray(b.enum),"KEYWORD_MUST_BE",{keyword:"enum",expression:"an array with unique items"})))},type:function(a,b){var c,e=["array","boolean","integer","number","null","object","string"],f=e.join(","),g=d.isString(b.type),h=d.isArray(b.type);c=a.expect(g||h,"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:["string","array"]}),c&&(h?(b.type.forEach(function(b){a.expect(-1!==e.indexOf(b),"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:f})},this),a.expect(d.isUniqueArray(b.type),"KEYWORD_MUST_BE",{keyword:"type",expression:"an object with unique properties"})):a.expect(-1!==e.indexOf(b.type),"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:f}),this.options.noZeroLengthStrings===!0&&("string"===b.type||h&&-1!==b.type.indexOf("string"))&&void 0===b.minLength&&(b.minLength=1),this.options.forceProperties===!0&&("object"===b.type||h&&-1!==b.type.indexOf("object"))&&a.expect(void 0!==b.properties||void 0!==b.patternProperties,"KEYWORD_UNDEFINED_STRICT",{keyword:"properties"}),this.options.forceItems===!0&&("array"===b.type||h&&-1!==b.type.indexOf("array"))&&a.expect(void 0!==b.items,"KEYWORD_UNDEFINED_STRICT",{keyword:"items"}),this.options.forceMaxLength===!0&&("string"===b.type||h&&-1!==b.type.indexOf("string"))&&a.expect(void 0!==b.maxLength||void 0!==b.format||void 0!==b.enum,"KEYWORD_UNDEFINED_STRICT",{keyword:"maxLength"}))},allOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.allOf),"KEYWORD_TYPE_EXPECTED",{keyword:"allOf",type:"array"}),c&&(c=a.expect(b.allOf.length>0,"KEYWORD_MUST_BE",{keyword:"allOf",expression:"an array with at least one element"}),c&&b.allOf.forEach(function(b,c){a.goDown("allOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},anyOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.anyOf),"KEYWORD_TYPE_EXPECTED",{keyword:"anyOf",type:"array"}),c&&(c=a.expect(b.anyOf.length>0,"KEYWORD_MUST_BE",{keyword:"anyOf",expression:"an array with at least one element"}),c&&b.anyOf.forEach(function(b,c){a.goDown("anyOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},oneOf:function(a,b){var c,e=this;c=a.expect(d.isArray(b.oneOf),"KEYWORD_TYPE_EXPECTED",{keyword:"oneOf",type:"array"}),c&&(c=a.expect(b.oneOf.length>0,"KEYWORD_MUST_BE",{keyword:"oneOf",expression:"an array with at least one element"}),c&&b.oneOf.forEach(function(b,c){a.goDown("oneOf["+c+"]"),e._validateSchema(a,b),a.goUp()}))},not:function(a,b){var c;c=a.expect(d.isObject(b.not),"KEYWORD_TYPE_EXPECTED",{keyword:"not",type:"object"}),c&&(a.goDown("not"),this._validateSchema(a,b.not),a.goUp())},definitions:function(a,b){var c,e=this;c=a.expect(d.isObject(b.definitions),"KEYWORD_TYPE_EXPECTED",{keyword:"definitions",type:"object"}),c&&d.forEach(b.definitions,function(b,c){a.goDown("definitions["+c+"]"),e._validateSchema(a,b),a.goUp()})},format:function(a,b){var c;c=a.expect(d.isString(b.format),"KEYWORD_TYPE_EXPECTED",{keyword:"format",type:"string"}),c&&(c=a.expect(d.isFunction(e[b.format])||d.isFunction(f[b.format]),"UNKNOWN_FORMAT",{format:b.format}))},id:function(a,b){a.expect(d.isString(b.id),"KEYWORD_TYPE_EXPECTED",{keyword:"id",type:"string"})},title:function(a,b){a.expect(d.isString(b.title),"KEYWORD_TYPE_EXPECTED",{keyword:"title",type:"string"})},description:function(a,b){a.expect(d.isString(b.description),"KEYWORD_TYPE_EXPECTED",{keyword:"description",type:"string"})},"default":function(){},__$compiled:function(b,c){a.expect.boolean(c.__$compiled)},__$validated:function(b,c){a.expect.boolean(c.__$validated)}},i={multipleOf:function(a,b,c){if(d.isNumber(c)){var e="integer"===d.whatIs(c/b.multipleOf);a.expect(e,"MULTIPLE_OF",{value:c,multipleOf:b.multipleOf})}},maximum:function(a,b,c){d.isNumber(c)&&(b.exclusiveMaximum!==!0?a.expect(c<=b.maximum,"MAXIMUM",{value:c,maximum:b.maximum}):a.expect(c<b.maximum,"MAXIMUM_EXCLUSIVE",{value:c,maximum:b.maximum}))},exclusiveMaximum:function(){},minimum:function(a,b,c){d.isNumber(c)&&(b.exclusiveMinimum!==!0?a.expect(c>=b.minimum,"MINIMUM",{value:c,minimum:b.minimum}):a.expect(c>b.minimum,"MINIMUM_EXCLUSIVE",{value:c,minimum:b.minimum}))},exclusiveMinimum:function(){},maxLength:function(a,b,c){d.isString(c)&&a.expect(c.length<=b.maxLength,"MAX_LENGTH",{length:c.length,maximum:b.maxLength})},minLength:function(a,b,c){d.isString(c)&&a.expect(c.length>=b.minLength,"MIN_LENGTH",{length:c.length,minimum:b.minLength})},pattern:function(a,b,c){d.isString(c)&&a.expect(d.getRegExp(b.pattern).test(c),"PATTERN",{pattern:b.pattern})},additionalItems:function(a,b,c){d.isArray(c)&&b.additionalItems===!1&&d.isArray(b.items)&&a.expect(c.length<=b.items.length,"ARRAY_ADDITIONAL_ITEMS")},items:function(){},maxItems:function(a,b,c){d.isArray(c)&&a.expect(c.length<=b.maxItems,"ARRAY_LENGTH_LONG",{length:c.length,maximum:b.maxItems})},minItems:function(a,b,c){d.isArray(c)&&a.expect(c.length>=b.minItems,"ARRAY_LENGTH_SHORT",{length:c.length,minimum:b.minItems})},uniqueItems:function(a,b,c){if(d.isArray(c)&&b.uniqueItems===!0){var e={};a.expect(d.isUniqueArray(c,e),"ARRAY_UNIQUE",e)}},maxProperties:function(a,b,c){d.isObject(c)&&a.expect(d.keys(c).length<=b.maxProperties,"OBJECT_PROPERTIES_MAXIMUM",{count:d.keys(c).length,maximum:b.maxProperties})},minProperties:function(a,b,c){d.isObject(c)&&a.expect(d.keys(c).length>=b.minProperties,"OBJECT_PROPERTIES_MINIMUM",{count:d.keys(c).length,minimum:b.maxProperties})},required:function(a,b,c){d.isObject(c)&&b.required.forEach(function(b){a.expect(void 0!==c[b],"OBJECT_REQUIRED",{property:b})})},additionalProperties:function(a,b){return void 0===b.properties&&void 0===b.patternProperties?i.properties.apply(this,arguments):void 0},properties:function(a,b,c){if(d.isObject(c)){var e=void 0!==b.properties?b.properties:{},f=void 0!==b.patternProperties?b.patternProperties:{};if(b.additionalProperties===!1){var g=d.keys(c),h=d.keys(e),i=d.keys(f);g=d.difference(g,h),i.forEach(function(a){for(var b=d.getRegExp(a),c=g.length-1;c>=0;c--)b.test(g[c])===!0&&g.splice(c,1)},this),a.expect(0===g.length,"OBJECT_ADDITIONAL_PROPERTIES",{properties:g})}}},patternProperties:function(a,b){return void 0===b.properties?i.properties.apply(this,arguments):void 0},dependencies:function(a,c,e){var f=this,g=b();return d.isObject(e)?(d.forEach(c.dependencies,function(b,c){g=g.then(function(){if(void 0!==e[c]){if(d.isObject(b))return f._validateObject(a,b,e);d.forEach(b,function(b){a.expect(void 0!==e[b],"OBJECT_DEPENDENCY_KEY",{missing:b,key:c})})}})}),g):void 0},"enum":function(a,b,c){for(var e=!1,f=0,g=b.enum.length;g>f;f++)if(d.areEqual(c,b.enum[f])){e=!0;break}a.expect(e,"ENUM_MISMATCH",{value:c})},type:function(a,b,c){var e=d.whatIs(c);if(d.isString(b.type))a.expect(e===b.type||"integer"===e&&"number"===b.type,"INVALID_TYPE",{expected:b.type,type:e});else{var f=-1!==b.type.indexOf(e),g="integer"===e&&-1!==b.type.indexOf("number");a.expect(f||g,"INVALID_TYPE",{expected:b.type,type:e})}},allOf:function(a,c,d){var e=this,f=b();return c.allOf.forEach(function(b){f=f.then(function(){return e._validateObject(a,b,d)})}),f},anyOf:function(a,c,d){var e=0,f=[],h=this,i=b();return c.anyOf.forEach(function(b){i=i.then(function(){if(!(e>0)){var c=new g(a);return h._validateObject(c,b,d).then(function(){c.isValid()?e++:f.push(c)})}})}),i.then(function(){a.expect(e>=1,"ANY_OF_MISSING",{},0===e?f:null)})},oneOf:function(a,c,d){var e=this,f=0,h=[],i=b();return c.oneOf.forEach(function(b){i=i.then(function(){var c=new g(a);return e._validateObject(c,b,d).then(function(){c.isValid()?f++:h.push(c)})})}),i.then(function(){a.expect(f>0,"ONE_OF_MISSING",{},0===f?h:null),a.expect(2>f,"ONE_OF_MULTIPLE")})},not:function(a,b,c){var d=new g(a);return this._validateObject(d,b.not,c).then(function(){a.expect(!d.isValid(),"NOT_PASSED")})},definitions:function(){},format:function(a,c,g){if("function"==typeof e[c.format])return a.expect(e[c.format](g),"FORMAT",{format:c.format,error:g}),void 0;var h=b.defer();try{var i=f[c.format](g,h.makeNodeResolver());(b.isPromise(i)||d.isBoolean(i))&&h.resolve(i)}catch(j){h.reject(j)}return h.promise.then(function(b){b||a.addError("FORMAT",{format:c.format})}).fail(function(b){a.addError("FORMAT",{format:c.format,error:b})})}};module.exports=a}();

Sorry, the diff of this file is too big to display

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