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.2.2 to 2.3.0

2

package.json

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

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

@@ -37,0 +37,0 @@ "bluebird": "~0.11.*"

@@ -15,3 +15,3 @@ # z-schema validator

Passing all tests here (even optional, except zeroTerminatedFloats):
Passing all tests here (even optional, except zeroTerminatedFloats and some URI tests, see more info in [#18](https://github.com/zaggino/z-schema/issues/18)):

@@ -235,2 +235,6 @@ [json-schema/JSON-Schema-Test-Suite](https://github.com/json-schema/JSON-Schema-Test-Suite)

* strictUris: ```true/false```
when true, uri's need to be in full rfc3986 format, by default checks for uri-fragment, more info in [#18](https://github.com/zaggino/z-schema/issues/18)
# Pull requests

@@ -237,0 +241,0 @@

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

/*! z-schema version 2.2.2 */
!function(){"use strict";function a(a){return/^https?\:\/\//.test(a)}function b(a){this.options=e.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 c=require("bluebird");c.prototype.fail=c.prototype.catch;var d=function(a,b,c,d){this.code=a,this.message=b,this.path=d||"",this.params=c||{}};d.prototype=new Error,d.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}"',SCHEMA_NOT_REACHABLE:"Validator was not able to read schema located at {uri}"},d.prototype.addSubError=function(a){this.subErrors||(this.subErrors=[]),this.subErrors.push(a)},d.createError=function(a,b,c){var e=d.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 d(a,e,b,c)};var e={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(e.isObject(a)){var d;for(d in a)a.hasOwnProperty(d)&&b.call(c,a[d],d)}},map:function(a,b,c){var d=-1,f=[];return e.forEach(a,function(a,e){f[++d]=b.call(c,a,e)}),f},defaults:function(a,b){return e.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,c){var e;try{e=JSON.parse(a)}catch(f){throw delete d._getRemoteSchemaCache[c],new Error("Not a JSON data at: "+c+", "+f)}e.id||(e.id=c),e.$schema||(e.$schema=c),e.__$downloadedFrom=c,b(void 0,e)}var d=this,e=a.split("#")[0];if(d._getRemoteSchemaCache[e])return c(d._getRemoteSchemaCache[e],e),void 0;var f=require("http");f.get(e,function(a){var b="";a.on("data",function(a){b+=a}),a.on("end",function(){c(d._getRemoteSchemaCache[e]=b,e)})}).on("error",function(a){b(a)})},resolveSchemaQuery:function(a,c,d,f){if(b.expect.string(d),"#"===d)return c;var g=null,h=d.split("#")[0],i=d.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=e.resolveSchemaId(c,h);else g=c;if(g&&i)for(var j=("#"+i).split("/");j.length>0;){var k=e.decodeJSONPointer(j.shift());-1===k.indexOf("#")?g=g[k]:"#"!==k&&(g=e.resolveSchemaId(g,k))}if(!g&&!f)throw new Error("Could not resolve schema reference: "+d);return g},resolveSchemaId:function(a,b){if(this.isObject(a)||this.isArray(a)){if(a.id===b)return a;var c=null;return e.forEach(a,function(a){c||(c=e.resolveSchemaId(a,b))}),c}}},f={date:function(a){if(!e.isString(a))return!0;var b=e.getRegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$").exec(a);if(null===b)return!1;var c=b[2],d=b[3];return"01">c||c>"12"||"01">d||d>"31"?!1:!0},"date-time":function(a){if(!e.isString(a))return!0;var b=a.toLowerCase().split("t");if(!f.date(b[0]))return!1;var c=e.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 d=c[1],g=c[2],h=c[3];return d>"23"||g>"59"||h>"59"?!1:!0},email:function(a){if(!e.isString(a))return!0;var b=e.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(!e.isString(a))return!0;if(-1===a.indexOf("."))return!1;var b=e.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 f.hostname.apply(this,arguments)},ipv4:function(a){if(!e.isString(a))return!0;var b=e.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(!e.isString(a))return!0;var b=e.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)},regex:function(a){try{return e.getRegExp(a),!0}catch(b){return!1}},uri:function(a){if(!e.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)}},g={},h=function(a){a&&(this.parentReport=a,e.forEach(a,function(a,b){this[b]=a},this)),this.errors=[],this.warnings=[],this.path=[]};h.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,c){var e=d.createError(a,b,this.getPath());return c&&c.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()?c.resolve(this):c.reject(this.toError())},goDown:function(a){this.path.push(a)},goUp:function(){this.path.pop()}},b.expect={typeError:function(a,b){return'Type mismatch, expected "'+a+'", got "'+e.whatIs(b)+'"'},"boolean":function(a){if(!e.isBoolean(a))throw new Error(b.expect.typeError("boolean",a))},string:function(a){if(!e.isString(a))throw new Error(b.expect.typeError("string",a))},callable:function(a){if(!e.isFunction(a))throw new Error(b.expect.typeError("function",a))},object:function(a){if(!e.isObject(a))throw new Error(b.expect.typeError("object",a))}},b.validate=function(){if(!this._defaultInstance){var a=this;this._defaultInstance=new a}return this._defaultInstance.validate.apply(this._defaultInstance,arguments)},b.registerFormat=function(a,c){if(b.expect.string(a),b.expect.callable(c),f[a])throw new Error("Cannot override built-in validator for "+a);if(g[a])throw new Error("Cannot override existing validator for "+a);g[a]=c},b.registerFormatSync=function(a,c){return c.__zSchemaSync=!0,b.registerFormat(a,c)},b.setRemoteReference=function(a,c){b.expect.string(c),e._getRemoteSchemaCache[a]=c},b.prototype.validate=function(a,b,c){var d=this,e=new h;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)},b.prototype.compileSchema=function(a,b){var c=this;if(Array.isArray(a))return c.compileSchemas(a);var d=new h;return this._compileSchema(d,a).then(function(a){return c._validateSchema(d,a).then(function(){return a})}).nodeify(b)},b.prototype.compileSchemas=function(a,b){function d(){if(0===a.length)return g.resolve();var b=a.shift();i.compileSchema(b).then(function(){k.push(b)}).catch(function(a){f=a,l.push(b)}).finally(function(){d()})}function e(){return 0===a.length?j.resolve(k):a.length===h?j.reject(f):(h=a.length,g=c.defer(),g.promise.then(function(){a=l,l=[],e()}),d(),void 0)}var f,g,h,i=this,j=c.defer(),k=[],l=[];return e(),j.promise.nodeify(b)},b.prototype.validateSchema=function(a,b){var c=new h;return this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},b.prototype._collectReferences=function k(a){var b=[];return a.$ref&&b.push(a),e.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(e.isObject(a)||e.isArray(a))&&(b=b.concat(k(a)))},this),b},b.prototype._compileSchema=function(a,b){if(b.__$compiled)return c.resolve(b);this._fixInnerReferences(b),this._fixOuterReferences(b);var d=this._collectReferences(b),f=e.uniq(d.map(function(a){return a.$ref})),g=this;return c.all(f.map(function(c){return 0!==c.indexOf(b.$schema)?0===c.indexOf("http:")||0===c.indexOf("https:")?g._downloadRemoteReferences(a,b,c.split("#")[0]):void 0:void 0})).then(function(){return d.forEach(function(c){c.__$refResolved||(c.__$refResolved=e.resolveSchemaQuery(c,b,c.$ref,!0)||null),g.schemaCache&&g.schemaCache[c.$ref]&&(c.__$refResolved=g.schemaCache[c.$ref]),a.expect(null!=c.__$refResolved,"UNRESOLVABLE_REFERENCE",{ref:c.$ref})}),a.isValid()&&(b.__$compiled=!0),b.id&&g.schemaCache&&(g.schemaCache[b.id]=b),b})},b.prototype._fixInnerReferences=function l(a,b){b||(b=a),b.$ref&&null!==b.__$refResolved&&0!==b.$ref.indexOf("http:")&&0!==b.$ref.indexOf("https:")&&(b.__$refResolved=e.resolveSchemaQuery(b,a,b.$ref,!0)||null),e.forEach(b,function(b,c){("string"!=typeof c||0!==c.indexOf("__"))&&(e.isObject(b)||e.isArray(b))&&l(a,b)},this)},b.prototype._fixOuterReferences=function m(b,c){if(c=c||[],e.isString(b.id)&&c.push(b.id),b.$ref&&!b.__$refResolved&&!a(b.$ref)&&c.length>0){var d=c.join("").split("#")[0];b.$ref="#"===b.$ref[0]?d+b.$ref:d.substring(0,1+d.lastIndexOf("/"))+b.$ref}e.forEach(b,function(a,b){("string"!=typeof b||0!==b.indexOf("__"))&&(e.isObject(a)||e.isArray(a))&&m(a,c)},this),e.isString(b.id)&&c.pop()},b.prototype._downloadRemoteReferences=function(a,b,d){var f=this,g=c.defer();return b.__remotes||(b.__remotes={}),b.id&&d===b.id.split("#")[0]?(b.__remotes[d]=b,g.resolve(),g.promise):(e.getRemoteSchema(d,function(c,e){return c?(c.description="Connection failed to: "+d,g.reject(c)):(g.resolve(f._compileSchema(a,e).then(function(a){b.__remotes[d]=a})),void 0)}),g.promise)},b.prototype._validateSchema=function(a,b){if(b.__$validated)return c.resolve(b);var d=this,f=b.$schema&&b.id!==b.$schema,g=function(){return d.options.noTypeless===!0&&a.expect(void 0!==b.type,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"}),e.forEach(b,function(c,e){("string"!=typeof e||0!==e.indexOf("__"))&&(void 0!==i[e]?i[e].call(d,a,b):f||(d.options.noExtraKeywords===!0?a.expect(!1,"KEYWORD_UNEXPECTED",{keyword:e}):a.addWarning('Unknown key "'+e+'" found in schema.')))}),a.isValid()&&(b.__$validated=!0),a.toPromise()};if(f){var h=c.defer();return e.getRemoteSchema(b.$schema,function(c,e){return c?(a.addError("SCHEMA_NOT_REACHABLE",{uri:b.$schema}),h.resolve(),void 0):(b.__$downloadedFrom!==e.__$downloadedFrom?d.validate(b,e,function(b){b&&(a.errors=a.errors.concat(b.errors)),h.resolve()}):h.resolve(),void 0)}),h.promise.then(g)}return g()},b.prototype._validateObject=function(a,d,f){b.expect.object(d);var g=this,h=!1;a.rootSchema||(a.rootSchema=d,h=!0);for(var i=99;d.$ref&&i>0;)d=d.__$refResolved?d.__$refResolved:e.resolveSchemaQuery(d,a.rootSchema,d.$ref),i--;return c.all(e.map(d,function(b,c){return void 0!==j[c]?j[c].call(g,a,d,f):void 0})).then(function(){return e.isArray(f)?g._recurseArray(a,d,f):e.isObject(f)?g._recurseObject(a,d,f):void 0}).then(function(){return h&&delete a.rootSchema,a})},b.prototype._recurseArray=function(a,b,d){var f=this,g=c.resolve();return e.isObject(b.items)?(d.forEach(function(c,d){g=g.then(function(){return a.goDown("["+d+"]"),f._validateObject(a,b.items,c).then(function(){a.goUp()})})}),g):e.isArray(b.items)?(d.forEach(function(c,d){g=g.then(function(){return d<b.items.length?(a.goDown("["+d+"]"),f._validateObject(a,b.items[d],c).then(function(){a.goUp()})):e.isObject(b.additionalItems)?(a.goDown("["+d+"]"),f._validateObject(a,b.additionalItems,c).then(function(){a.goUp()})):void 0})}),g):void 0},b.prototype._recurseObject=function(a,b,d){var f=this,g=c.resolve(),h=b.additionalProperties;(h===!0||void 0===h)&&(h={});var i=e.keys(b.properties||{}),j=e.keys(b.patternProperties||{});return e.forEach(d,function(c,d){var k=[];-1!==i.indexOf(d)&&k.push(b.properties[d]),j.forEach(function(a){e.getRegExp(a).test(d)===!0&&k.push(b.patternProperties[a])},this),0===k.length&&h!==!1&&k.push(h),k.forEach(function(b){g=g.then(function(){return a.goDown(d),f._validateObject(a,b,c).then(function(){a.goUp()})})})}),g};var i={$ref:function(a,b){a.expect(e.isString(b.$ref),"KEYWORD_TYPE_EXPECTED",{keyword:"$ref",type:"string"})},$schema:function(a,b){a.expect(e.isString(b.$schema),"KEYWORD_TYPE_EXPECTED",{keyword:"$schema",type:"string"})},multipleOf:function(a,b){var c=a.expect(e.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(e.isNumber(b.maximum),"KEYWORD_TYPE_EXPECTED",{keyword:"maximum",type:"number"})},exclusiveMaximum:function(a,b){var c=a.expect(e.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(e.isNumber(b.minimum),"KEYWORD_TYPE_EXPECTED",{keyword:"minimum",type:"number"})},exclusiveMinimum:function(a,b){var c=a.expect(e.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(e.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(e.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(e.isString(b.pattern),"KEYWORD_TYPE_EXPECTED",{keyword:"pattern",type:"string"});if(c)try{e.getRegExp(b.pattern)}catch(d){a.addError("KEYWORD_PATTERN",{keyword:"pattern",pattern:b.pattern})}},additionalItems:function(a,b){var c=e.isBoolean(b.additionalItems),d=e.isObject(b.additionalItems),f=a.expect(c||d,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalItems",type:["boolean","object"]});f&&d&&(a.goDown("additionalItems"),this._validateSchema(a,b.additionalItems),a.goUp())},items:function(a,b){var c=this,d=e.isArray(b.items),f=e.isObject(b.items),g=a.expect(d||f,"KEYWORD_TYPE_EXPECTED",{keyword:"items",type:["array","object"]});g&&(f?(a.goDown("items"),this._validateSchema(a,b.items),a.goUp()):d&&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(e.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(e.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(e.isBoolean(b.uniqueItems),"KEYWORD_TYPE_EXPECTED",{keyword:"uniqueItems",type:"boolean"})},maxProperties:function(a,b){var c=a.expect(e.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(e.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(e.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(e.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"required",type:"string"})},this),a.expect(e.isUniqueArray(b.required),"KEYWORD_MUST_BE",{keyword:"required",expression:"an array with unique items"})))},additionalProperties:function(a,b){var c=e.isBoolean(b.additionalProperties),d=e.isObject(b.additionalProperties),f=a.expect(c||d,"KEYWORD_TYPE_EXPECTED",{keyword:"additionalProperties",type:["boolean","object"]});f&&d&&(a.goDown("additionalProperties"),this._validateSchema(a,b.additionalProperties),a.goUp())},properties:function(a,b){var c=this,d=a.expect(e.isObject(b.properties),"KEYWORD_TYPE_EXPECTED",{keyword:"properties",type:"object"});d&&(e.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,d=a.expect(e.isObject(b.patternProperties),"KEYWORD_TYPE_EXPECTED",{keyword:"patternProperties",type:"object"});d&&e.forEach(b.patternProperties,function(b,d){try{e.getRegExp(d)}catch(f){a.addError("KEYWORD_PATTERN",{keyword:"patternProperties",pattern:d})}a.goDown("patternProperties["+d+"]"),c._validateSchema(a,b),a.goUp()})},dependencies:function(a,b){var c=this,d=a.expect(e.isObject(b.dependencies),"KEYWORD_TYPE_EXPECTED","dependencies","object");d&&e.forEach(b.dependencies,function(b,d){var f=e.isObject(b),g=e.isArray(b);a.expect(f||g,"KEYWORD_VALUE_TYPE",{keyword:"dependencies",type:"object or array"}),f?(a.goDown("dependencies["+d+"]"),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(e.isString(b),"KEYWORD_VALUE_TYPE",{keyword:"dependensices",type:"string"})}),a.expect(e.isUniqueArray(b),{keyword:"dependencies",expression:"an array with unique items"}))})},"enum":function(a,b){var c;c=a.expect(e.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(e.isUniqueArray(b.enum),"KEYWORD_MUST_BE",{keyword:"enum",expression:"an array with unique items"})))},type:function(a,b){var c,d=["array","boolean","integer","number","null","object","string"],f=d.join(","),g=e.isString(b.type),h=e.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!==d.indexOf(b),"KEYWORD_TYPE_EXPECTED",{keyword:"type",type:f})},this),a.expect(e.isUniqueArray(b.type),"KEYWORD_MUST_BE",{keyword:"type",expression:"an object with unique properties"})):a.expect(-1!==d.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,d=this;c=a.expect(e.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+"]"),d._validateSchema(a,b),a.goUp()}))},anyOf:function(a,b){var c,d=this;c=a.expect(e.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+"]"),d._validateSchema(a,b),a.goUp()}))},oneOf:function(a,b){var c,d=this;c=a.expect(e.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+"]"),d._validateSchema(a,b),a.goUp()}))},not:function(a,b){var c;c=a.expect(e.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,d=this;c=a.expect(e.isObject(b.definitions),"KEYWORD_TYPE_EXPECTED",{keyword:"definitions",type:"object"}),c&&e.forEach(b.definitions,function(b,c){a.goDown("definitions["+c+"]"),d._validateSchema(a,b),a.goUp()})},format:function(a,b){var c;c=a.expect(e.isString(b.format),"KEYWORD_TYPE_EXPECTED",{keyword:"format",type:"string"}),c&&(c=a.expect(e.isFunction(f[b.format])||e.isFunction(g[b.format]),"UNKNOWN_FORMAT",{format:b.format}))},id:function(a,b){a.expect(e.isString(b.id),"KEYWORD_TYPE_EXPECTED",{keyword:"id",type:"string"})},title:function(a,b){a.expect(e.isString(b.title),"KEYWORD_TYPE_EXPECTED",{keyword:"title",type:"string"})},description:function(a,b){a.expect(e.isString(b.description),"KEYWORD_TYPE_EXPECTED",{keyword:"description",type:"string"})},"default":function(){},__$compiled:function(a,c){b.expect.boolean(c.__$compiled)},__$validated:function(a,c){b.expect.boolean(c.__$validated)}},j={multipleOf:function(a,b,c){if(e.isNumber(c)){var d="integer"===e.whatIs(c/b.multipleOf);a.expect(d,"MULTIPLE_OF",{value:c,multipleOf:b.multipleOf})}},maximum:function(a,b,c){e.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){e.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){e.isString(c)&&a.expect(c.length<=b.maxLength,"MAX_LENGTH",{length:c.length,maximum:b.maxLength})},minLength:function(a,b,c){e.isString(c)&&a.expect(c.length>=b.minLength,"MIN_LENGTH",{length:c.length,minimum:b.minLength})},pattern:function(a,b,c){e.isString(c)&&a.expect(e.getRegExp(b.pattern).test(c),"PATTERN",{pattern:b.pattern})},additionalItems:function(a,b,c){e.isArray(c)&&b.additionalItems===!1&&e.isArray(b.items)&&a.expect(c.length<=b.items.length,"ARRAY_ADDITIONAL_ITEMS")},items:function(){},maxItems:function(a,b,c){e.isArray(c)&&a.expect(c.length<=b.maxItems,"ARRAY_LENGTH_LONG",{length:c.length,maximum:b.maxItems})},minItems:function(a,b,c){e.isArray(c)&&a.expect(c.length>=b.minItems,"ARRAY_LENGTH_SHORT",{length:c.length,minimum:b.minItems})},uniqueItems:function(a,b,c){if(e.isArray(c)&&b.uniqueItems===!0){var d={};a.expect(e.isUniqueArray(c,d),"ARRAY_UNIQUE",d)}},maxProperties:function(a,b,c){e.isObject(c)&&a.expect(e.keys(c).length<=b.maxProperties,"OBJECT_PROPERTIES_MAXIMUM",{count:e.keys(c).length,maximum:b.maxProperties})},minProperties:function(a,b,c){e.isObject(c)&&a.expect(e.keys(c).length>=b.minProperties,"OBJECT_PROPERTIES_MINIMUM",{count:e.keys(c).length,minimum:b.maxProperties})},required:function(a,b,c){e.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?j.properties.apply(this,arguments):void 0},properties:function(a,b,c){if(e.isObject(c)){var d=void 0!==b.properties?b.properties:{},f=void 0!==b.patternProperties?b.patternProperties:{};if(b.additionalProperties===!1){var g=e.keys(c),h=e.keys(d),i=e.keys(f);g=e.difference(g,h),i.forEach(function(a){for(var b=e.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?j.properties.apply(this,arguments):void 0},dependencies:function(a,b,d){var f=this,g=c.resolve();return e.isObject(d)?(e.forEach(b.dependencies,function(b,c){g=g.then(function(){if(void 0!==d[c]){if(e.isObject(b))return f._validateObject(a,b,d);e.forEach(b,function(b){a.expect(void 0!==d[b],"OBJECT_DEPENDENCY_KEY",{missing:b,key:c})})}})}),g):void 0},"enum":function(a,b,c){for(var d=!1,f=0,g=b.enum.length;g>f;f++)if(e.areEqual(c,b.enum[f])){d=!0;break}a.expect(d,"ENUM_MISMATCH",{value:c})},type:function(a,b,c){var d=e.whatIs(c);if(e.isString(b.type))a.expect(d===b.type||"integer"===d&&"number"===b.type,"INVALID_TYPE",{expected:b.type,type:d});else{var f=-1!==b.type.indexOf(d),g="integer"===d&&-1!==b.type.indexOf("number");a.expect(f||g,"INVALID_TYPE",{expected:b.type,type:d})}},allOf:function(a,b,d){var e=this,f=c.resolve();return b.allOf.forEach(function(b){f=f.then(function(){return e._validateObject(a,b,d)})}),f},anyOf:function(a,b,d){var e=0,f=[],g=this,i=c.resolve();return b.anyOf.forEach(function(b){i=i.then(function(){if(!(e>0)){var c=new h(a);return g._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,b,d){var e=this,f=0,g=[];return c.all(b.oneOf.map(function(b){var c=new h(a);return e._validateObject(c,b,d).then(function(){c.isValid()?f++:g.push(c)})})).then(function(){a.expect(f>0,"ONE_OF_MISSING",{},0===f?g:null),a.expect(2>f,"ONE_OF_MULTIPLE")})},not:function(a,b,c){var d=new h(a);return this._validateObject(d,b.not,c).then(function(){a.expect(!d.isValid(),"NOT_PASSED")})},definitions:function(){},format:function(a,b,d){var h;if("function"==typeof f[b.format])return a.expect(f[b.format](d),"FORMAT",{format:b.format,error:d}),void 0;{if(g[b.format].__zSchemaSync!==!0){var i=c.defer();try{h=g[b.format](d,i.callback),(c.is(h)||e.isBoolean(h))&&i.resolve(h)}catch(j){i.reject(j)}return i.promise.then(function(c){c||a.addError("FORMAT",{format:b.format})}).catch(function(c){a.addError("FORMAT",{format:b.format,error:c})})}try{h=g[b.format](d),h!==!0&&a.addError("FORMAT",{format:b.format})}catch(k){a.addError("FORMAT",{format:b.format,error:k})}}}};module.exports=b
}();
/*! z-schema version 2.3.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,strictUris:!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("bluebird");b.prototype.fail=b.prototype.catch;var 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}"',SCHEMA_NOT_REACHABLE:"Validator was not able to read schema located at {uri}"},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},isAbsoluteUri:function(a){return d.getRegExp("^https?://").test(a)},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,c){var e;try{e=JSON.parse(a)}catch(f){throw delete d._getRemoteSchemaCache[c],new Error("Not a JSON data at: "+c+", "+f)}e.id||(e.id=c),e.$schema||(e.$schema=c),e.__$downloadedFrom=c,b(void 0,e)}var d=this,e=a.split("#")[0];if(d._getRemoteSchemaCache[e])return c(d._getRemoteSchemaCache[e],e),void 0;var f=require("http");f.get(e,function(a){var b="";a.on("data",function(a){b+=a}),a.on("end",function(){c(d._getRemoteSchemaCache[e]=b,e)})}).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){return"string"!=typeof a||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).test(a)},hostname:function(a){return d.isString(a)?-1===a.indexOf(".")?!1: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])$").test(a):!0},"host-name":function(){return e.hostname.apply(this,arguments)},ipv4:function(a){return"string"!=typeof a||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]?)$").test(a)},ipv6:function(a){return"string"!=typeof a||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*$").test(a)},regex:function(a){try{return d.getRegExp(a),!0}catch(b){return!1}},uri:function(a,b){return b.options.strictUris?e["strict-uri"].apply(this,arguments):"string"!=typeof a||d.getRegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(a)},"strict-uri":function(a){return"string"!=typeof a||d.getRegExp("^(?:(?: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").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.resolve(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.registerFormatSync=function(b,c){return c.__zSchemaSync=!0,a.registerFormat(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;if(Array.isArray(a))return c.compileSchemas(a);var d=new g;return this._compileSchema(d,a).then(function(a){return c._validateSchema(d,a).then(function(){return a})}).nodeify(b)},a.prototype.compileSchemas=function(a,c){function d(){if(0===a.length)return g.resolve();var b=a.shift();i.compileSchema(b).then(function(){k.push(b)}).catch(function(a){f=a,l.push(b)}).finally(function(){d()})}function e(){return 0===a.length?j.resolve(k):a.length===h?j.reject(f):(h=a.length,g=b.defer(),g.promise.then(function(){a=l,l=[],e()}),d(),void 0)}var f,g,h,i=this,j=b.defer(),k=[],l=[];return e(),j.promise.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.resolve(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&&!d.isAbsoluteUri(a.$ref)&&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.resolve(c);var e=this,f=c.$schema&&c.id!==c.$schema,g=function(){return e.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):f||(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()};if(f){var i=b.defer();return d.getRemoteSchema(c.$schema,function(b,d){return b?(a.addError("SCHEMA_NOT_REACHABLE",{uri:c.$schema}),i.resolve(),void 0):(c.__$downloadedFrom!==d.__$downloadedFrom?e.validate(c,d,function(b){b&&(a.errors=a.errors.concat(b.errors)),i.resolve()}):i.resolve(),void 0)}),i.promise.then(g)}return g()},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,b){return void 0!==i[b]?i[b].call(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.resolve();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.resolve(),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.resolve();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.resolve();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.resolve();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=[];return b.all(c.oneOf.map(function(b){var c=new g(a);return e._validateObject(c,b,d).then(function(){c.isValid()?f++:h.push(c)})})).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){var h;if("function"==typeof e[c.format])return a.expect(e[c.format](g,this),"FORMAT",{format:c.format,error:g}),void 0;{if(f[c.format].__zSchemaSync!==!0){var i=b.defer();try{h=f[c.format](g,i.callback),(b.is(h)||d.isBoolean(h))&&i.resolve(h)}catch(j){i.reject(j)}return i.promise.then(function(b){b||a.addError("FORMAT",{format:c.format})}).catch(function(b){a.addError("FORMAT",{format:c.format,error:b})
})}try{h=f[c.format](g),h!==!0&&a.addError("FORMAT",{format:c.format})}catch(k){a.addError("FORMAT",{format:c.format,error:k})}}}};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