Comparing version 2.3.1 to 2.4.0
@@ -34,15 +34,15 @@ { | ||
"files": ["src/ZSchema.js", "src/ZSchema.min.js", "LICENSE", "README.md"], | ||
"version": "2.3.1", | ||
"version": "2.4.0", | ||
"dependencies": { | ||
"bluebird": "~0.11.*", | ||
"request": "~2.30.*" | ||
"bluebird": "~1.0.*", | ||
"request": "~2.31.*" | ||
}, | ||
"devDependencies": { | ||
"chai": "1.8.1", | ||
"grunt": "0.4.1", | ||
"grunt-contrib-uglify": "0.2.4", | ||
"grunt-contrib-jshint": "0.6.4", | ||
"grunt-simple-mocha": "0.4.0", | ||
"mocha": "1.13.0", | ||
"uglify-js": "2.4.0" | ||
"chai": "latest", | ||
"grunt": "latest", | ||
"grunt-contrib-uglify": "latest", | ||
"grunt-contrib-jshint": "latest", | ||
"grunt-simple-mocha": "latest", | ||
"mocha": "latest", | ||
"uglify-js": "latest" | ||
}, | ||
@@ -49,0 +49,0 @@ "bugs": { |
# z-schema validator | ||
[![NPM version](https://badge.fury.io/js/z-schema.png)](http://badge.fury.io/js/z-schema) | ||
[![Dependency Status](https://gemnasium.com/zaggino/z-schema.png)](https://gemnasium.com/zaggino/z-schema) | ||
[![Dependency Status](https://david-dm.org/zaggino/z-schema.png?theme=shields.io)](https://david-dm.org/zaggino/z-schema) | ||
@@ -38,2 +38,8 @@ JSON Schema validator for Node.js (draft4 version) | ||
There is also support for _sync_ mode like this: | ||
```javascript | ||
var validator = new ZSchema({ sync: true }); | ||
var valid = validator.validate(json, schema); | ||
``` | ||
Using traditional callback: | ||
@@ -40,0 +46,0 @@ ```javascript |
@@ -1,3 +0,3 @@ | ||
/*! z-schema version 2.3.1 */ | ||
!function(){"use strict";function a(a){this.options=e.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"),c=require("request");b.prototype.fail=b.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 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}",SCHEMA_TYPE_EXPECTED:'Schema is expected to be of type "object"'},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},isAbsoluteUri:function(a){return e.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(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 d(a,c){var d;try{d=JSON.parse(a)}catch(f){throw delete e._getRemoteSchemaCache[c],new Error("Not a JSON data at: "+c+", "+f)}d.id||(d.id=c),d.$schema||(d.$schema=c),d.__$downloadedFrom=c,b(void 0,d)}var e=this,f=a.split("#")[0];return e._getRemoteSchemaCache[f]?(d(e._getRemoteSchemaCache[f],f),void 0):(c(f,function(a,c,g){return a?(b(a),void 0):(d(e._getRemoteSchemaCache[f]=g,f),void 0)}),void 0)},resolveSchemaQuery:function(b,c,d,f){if(a.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){return"string"!=typeof a||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).test(a)},hostname:function(a){return e.isString(a)?-1===a.indexOf(".")?!1: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])$").test(a):!0},"host-name":function(){return f.hostname.apply(this,arguments)},ipv4:function(a){return"string"!=typeof a||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]?)$").test(a)},ipv6:function(a){return"string"!=typeof a||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*$").test(a)},regex:function(a){try{return e.getRegExp(a),!0}catch(b){return!1}},uri:function(a,b){return b.options.strictUris?f["strict-uri"].apply(this,arguments):"string"!=typeof a||e.getRegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(a)},"strict-uri":function(a){return"string"!=typeof a||e.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)}},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()?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 "'+e.whatIs(b)+'"'},"boolean":function(b){if(!e.isBoolean(b))throw new Error(a.expect.typeError("boolean",b))},string:function(b){if(!e.isString(b))throw new Error(a.expect.typeError("string",b))},callable:function(b){if(!e.isFunction(b))throw new Error(a.expect.typeError("function",b))},object:function(b){if(!e.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),f[b])throw new Error("Cannot override built-in validator for "+b);if(g[b])throw new Error("Cannot override existing validator for "+b);g[b]=c},a.registerFormatSync=function(b,c){return c.__zSchemaSync=!0,a.registerFormat(b,c)},a.setRemoteReference=function(b,c){a.expect.string(c),e._getRemoteSchemaCache[b]=c},a.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)},a.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)},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 h;return c.expect(e.isObject(a),"SCHEMA_TYPE_EXPECTED"),this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},a.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},a.prototype._compileSchema=function(a,c){if(c.__$compiled)return b.resolve(c);this._fixInnerReferences(c),this._fixOuterReferences(c);var d=this._collectReferences(c),f=e.uniq(d.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 d.forEach(function(b){b.__$refResolved||(b.__$refResolved=e.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 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)},a.prototype._fixOuterReferences=function m(a,b){if(b=b||[],e.isString(a.id)&&b.push(a.id),a.$ref&&!a.__$refResolved&&!e.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}e.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(e.isObject(a)||e.isArray(a))&&m(a,b)},this),e.isString(a.id)&&b.pop()},a.prototype._downloadRemoteReferences=function(a,c,d){var f=this,g=b.defer();return c.__remotes||(c.__remotes={}),c.id&&d===c.id.split("#")[0]?(c.__remotes[d]=c,g.resolve(),g.promise):(e.getRemoteSchema(d,function(b,e){return b?(b.description="Connection failed to: "+d,g.reject(b)):(g.resolve(f._compileSchema(a,e).then(function(a){c.__remotes[d]=a})),void 0)}),g.promise)},a.prototype._validateSchema=function(a,c){if(c.__$validated)return b.resolve(c);var d=this,f=c.$schema&&c.id!==c.$schema,g=function(){return d.options.noTypeless===!0&&a.expect(void 0!==c.type,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"}),e.forEach(c,function(b,e){("string"!=typeof e||0!==e.indexOf("__"))&&(void 0!==i[e]?i[e].call(d,a,c):f||(d.options.noExtraKeywords===!0?a.expect(!1,"KEYWORD_UNEXPECTED",{keyword:e}):a.addWarning('Unknown key "'+e+'" found in schema.')))}),a.isValid()&&(c.__$validated=!0),a.toPromise()};if(f){var h=b.defer();return e.getRemoteSchema(c.$schema,function(b,e){return b?(a.addError("SCHEMA_NOT_REACHABLE",{uri:c.$schema}),h.resolve(),void 0):(c.__$downloadedFrom!==e.__$downloadedFrom?d.validate(c,e,function(b){b&&(a.errors=a.errors.concat(b.errors)),h.resolve()}):h.resolve(),void 0)}),h.promise.then(g)}return g()},a.prototype._validateObject=function(c,d,f){a.expect.object(d);var g=this,h=!1;c.rootSchema||(c.rootSchema=d,h=!0);for(var i=99;d.$ref&&i>0;)d=d.__$refResolved?d.__$refResolved:e.resolveSchemaQuery(d,c.rootSchema,d.$ref),i--;return b.all(e.map(d,function(a,b){return void 0!==j[b]?j[b].call(g,c,d,f):void 0})).then(function(){return e.isArray(f)?g._recurseArray(c,d,f):e.isObject(f)?g._recurseObject(c,d,f):void 0}).then(function(){return h&&delete c.rootSchema,c})},a.prototype._recurseArray=function(a,c,d){var f=this,g=b.resolve();return e.isObject(c.items)?(d.forEach(function(b,d){g=g.then(function(){return a.goDown("["+d+"]"),f._validateObject(a,c.items,b).then(function(){a.goUp()})})}),g):e.isArray(c.items)?(d.forEach(function(b,d){g=g.then(function(){return d<c.items.length?(a.goDown("["+d+"]"),f._validateObject(a,c.items[d],b).then(function(){a.goUp()})):e.isObject(c.additionalItems)?(a.goDown("["+d+"]"),f._validateObject(a,c.additionalItems,b).then(function(){a.goUp()})):void 0})}),g):void 0},a.prototype._recurseObject=function(a,c,d){var f=this,g=b.resolve(),h=c.additionalProperties;(h===!0||void 0===h)&&(h={});var i=e.keys(c.properties||{}),j=e.keys(c.patternProperties||{});return e.forEach(d,function(b,d){var k=[];-1!==i.indexOf(d)&&k.push(c.properties[d]),j.forEach(function(a){e.getRegExp(a).test(d)===!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(d),f._validateObject(a,c,b).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(b,c){a.expect.boolean(c.__$compiled)},__$validated:function(b,c){a.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,c,d){var f=this,g=b.resolve();return e.isObject(d)?(e.forEach(c.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,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=[],g=this,i=b.resolve();return c.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,c,d){var e=this,f=0,g=[];return b.all(c.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,c,d){var h;if("function"==typeof f[c.format])return a.expect(f[c.format](d,this),"FORMAT",{format:c.format,error:d}),void 0;{if(g[c.format].__zSchemaSync!==!0){var i=b.defer();try{h=g[c.format](d,i.callback),(b.is(h)||e.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=g[c.format](d),h!==!0&&a.addError("FORMAT",{format:c.format})}catch(k){a.addError("FORMAT",{format:c.format,error:k})}}}};module.exports=a}(); | ||
/*! z-schema version 2.4.0 */ | ||
!function(){"use strict";function a(a){this.options=e.defaults(a||{},{noExtraKeywords:!1,noZeroLengthStrings:!1,noTypeless:!1,forceAdditional:!1,forceProperties:!1,forceItems:!1,forceMaxLength:!1,noSchemaCache:!1,strictUris:!1,sync:!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"),c=require("request");b.prototype.fail=b.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 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}",SCHEMA_TYPE_EXPECTED:'Schema is expected to be of type "object"'},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)&&a%1===0},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 e.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(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 d(a,c){var d;try{d=JSON.parse(a)}catch(f){throw delete e._getRemoteSchemaCache[c],new Error("Not a JSON data at: "+c+", "+f)}return d.id||(d.id=c),d.$schema||(d.$schema=c),d.__$downloadedFrom=c,b?b(void 0,d):d}var e=this,f=a.split("#")[0];return e._getRemoteSchemaCache[f]?d(e._getRemoteSchemaCache[f],f):(b&&c(f,function(a,c,g){return a?(b(a),void 0):(d(e._getRemoteSchemaCache[f]=g,f),void 0)}),void 0)},resolveSchemaQuery:function(b,c,d,f,g){if(a.expect.string(d),"#"===d)return c;var h=null,i=d.split("#")[0],j=d.split("#")[1];if(i)if(0===i.indexOf("http:")||0===i.indexOf("https:")){if(!c.__remotes||!c.__remotes[i])throw g?new Error("Use .setRemoteReference to download references in sync mode: "+i):new Error("Remote is not downloaded: "+i);h=c.__remotes[i]}else h=e.resolveSchemaId(c,i);else h=c;if(h&&j)for(var k=("#"+j).split("/");k.length>0;){var l=e.decodeJSONPointer(k.shift());-1===l.indexOf("#")?h=h[l]:"#"!==l&&(h=e.resolveSchemaId(h,l))}if(!h&&!f)throw new Error("Could not resolve schema reference: "+d);return h},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){return"string"!=typeof a||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).test(a)},hostname:function(a){return e.isString(a)?-1===a.indexOf(".")?!1: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])$").test(a):!0},"host-name":function(){return f.hostname.apply(this,arguments)},ipv4:function(a){return"string"!=typeof a||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]?)$").test(a)},ipv6:function(a){return"string"!=typeof a||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*$").test(a)},regex:function(a){try{return e.getRegExp(a),!0}catch(b){return!1}},uri:function(a,b){return b.options.strictUris?f["strict-uri"].apply(this,arguments):"string"!=typeof a||e.getRegExp("^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?").test(a)},"strict-uri":function(a){return"string"!=typeof a||e.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)}},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()?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 "'+e.whatIs(b)+'"'},"boolean":function(b){if(!e.isBoolean(b))throw new Error(a.expect.typeError("boolean",b))},string:function(b){if(!e.isString(b))throw new Error(a.expect.typeError("string",b))},callable:function(b){if(!e.isFunction(b))throw new Error(a.expect.typeError("function",b))},object:function(b){if(!e.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),f[b])throw new Error("Cannot override built-in validator for "+b);if(g[b])throw new Error("Cannot override existing validator for "+b);g[b]=c},a.registerFormatSync=function(b,c){return c.__$sync=!0,a.registerFormat(b,c)},a.setRemoteReference=function(b,c){a.expect.string(c),e._getRemoteSchemaCache[b]=c},a.prototype.validate=function(a,b,c){var d=this,e=new h;return this.options.sync?(b.__$compiled||this._compileSchema(e,b),b.__$validated||this._validateSchema(e,b),this._validateObject(e,b,a),this._lastError=e.toJSON(),e.isValid()):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.getLastError=function(){return this._lastError},a.prototype.compileSchema=function(a,b){var c=this;if(Array.isArray(a))return this.options.sync?this.compileSchemasSync(a):this.compileSchemas(a);var d=new h;return this.options.sync?(this._compileSchema(d,a),this._validateSchema(d,a),this._lastError=d.toJSON(),d.isValid()):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.compileSchemasSync=function(){throw new Error("NOT IMPLEMENTED")},a.prototype.validateSchema=function(a,b){var c=new h;return c.expect(e.isObject(a),"SCHEMA_TYPE_EXPECTED"),this.options.sync?(this._validateSchema(c,a),this._lastError=c.toJSON(),c.isValid()):this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},a.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},a.prototype._compileSchema=function(a,c){function d(){return g.forEach(function(b){b.__$refResolved||(b.__$refResolved=e.resolveSchemaQuery(b,c,b.$ref,!0,i.options.sync)||null),i.schemaCache&&i.schemaCache[b.$ref]&&(b.__$refResolved=i.schemaCache[b.$ref]),a.expect(null!=b.__$refResolved,"UNRESOLVABLE_REFERENCE",{ref:b.$ref})}),a.isValid()&&(c.__$compiled=!0),c.id&&i.schemaCache&&(i.schemaCache[c.id]=c),c}function f(){return h.map(function(b){return 0!==b.indexOf(c.$schema)?0===b.indexOf("http:")||0===b.indexOf("https:")?i._downloadRemoteReferences(a,c,b.split("#")[0]):void 0:void 0})}if(c.__$compiled)return this.options.sync?c:b.resolve(c);this._fixInnerReferences(c),this._fixOuterReferences(c);var g=this._collectReferences(c),h=e.uniq(g.map(function(a){return a.$ref})),i=this;return this.options.sync?(f(),d(),void 0):b.all(f()).then(d)},a.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,this.options.sync)||null),e.forEach(b,function(b,c){("string"!=typeof c||0!==c.indexOf("__"))&&(e.isObject(b)||e.isArray(b))&&l.call(this,a,b)},this)},a.prototype._fixOuterReferences=function m(a,b){if(b=b||[],e.isString(a.id)&&b.push(a.id),a.$ref&&!a.__$refResolved&&!e.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}e.forEach(a,function(a,c){("string"!=typeof c||0!==c.indexOf("__"))&&(e.isObject(a)||e.isArray(a))&&m(a,b)},this),e.isString(a.id)&&b.pop()},a.prototype._downloadRemoteReferences=function(a,c,d){if(c.__remotes||(c.__remotes={}),c.id&&d===c.id.split("#")[0])return c.__remotes[d]=c,this.options.sync?null:b.resolve();if(!this.options.sync){var f=this,g=b.defer();return e.getRemoteSchema(d,function(b,e){return b?(b.description="Connection failed to: "+d,g.reject(b)):(g.resolve(f._compileSchema(a,e).then(function(a){c.__remotes[d]=a})),void 0)}),g.promise}var h=e.getRemoteSchema(d);h&&(this._compileSchema(a,h),c.__remotes[d]=h)},a.prototype._validateSchema=function(a,c){if(c.__$validated)return this.options.sync?c:b.resolve(c);var d=this,f=c.$schema&&c.id!==c.$schema,g=function(){return d.options.noTypeless===!0&&a.expect(void 0!==c.type,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"}),e.forEach(c,function(b,e){("string"!=typeof e||0!==e.indexOf("__"))&&(void 0!==i[e]?i[e].call(d,a,c):f||(d.options.noExtraKeywords===!0?a.expect(!1,"KEYWORD_UNEXPECTED",{keyword:e}):a.addWarning('Unknown key "'+e+'" found in schema.')))}),a.isValid()&&(c.__$validated=!0),d._lastError=a.toJSON(),d.options.sync?a.isValid():a.toPromise()};if(f){if(this.options.sync)return g();var h=b.defer();return e.getRemoteSchema(c.$schema,function(b,e){return b?(a.addError("SCHEMA_NOT_REACHABLE",{uri:c.$schema}),h.resolve(),void 0):(c.__$downloadedFrom!==e.__$downloadedFrom?d.validate(c,e,function(b){b&&(a.errors=a.errors.concat(b.errors)),h.resolve()}):h.resolve(),void 0)}),h.promise.then(g)}return g()},a.prototype._validateObject=function(c,d,f){function g(a,b){return void 0!==j[b]?j[b].call(k,c,d,f):void 0}function h(){return e.isArray(f)?k._recurseArray(c,d,f):e.isObject(f)?k._recurseObject(c,d,f):void 0}function i(){return l&&delete c.rootSchema,c}a.expect.object(d);var k=this,l=!1;c.rootSchema||(c.rootSchema=d,l=!0);for(var m=99;d.$ref&&m>0;)d=d.__$refResolved?d.__$refResolved:e.resolveSchemaQuery(d,c.rootSchema,d.$ref,!1,k.options.sync),m--;return this.options.sync?(e.forEach(d,g),h(),i(),k._lastError=c.toJSON(),c.isValid()):b.all(e.map(d,g)).then(h).then(i)},a.prototype._recurseArray=function(a,c,d){var f,g=this;return e.isObject(c.items)?this.options.sync?(d.forEach(function(b,d){a.goDown("["+d+"]"),this._validateObject(a,c.items,b),a.goUp()},this),void 0):(f=b.resolve(),d.forEach(function(b,d){f=f.then(function(){return a.goDown("["+d+"]"),g._validateObject(a,c.items,b).then(function(){a.goUp()})})}),f):e.isArray(c.items)?this.options.sync?(d.forEach(function(b,d){d<c.items.length?(a.goDown("["+d+"]"),this._validateObject(a,c.items[d],b),a.goUp()):e.isObject(c.additionalItems)&&(a.goDown("["+d+"]"),this._validateObject(a,c.additionalItems,b),a.goUp())},this),void 0):(f=b.resolve(),d.forEach(function(b,d){f=f.then(function(){return d<c.items.length?(a.goDown("["+d+"]"),g._validateObject(a,c.items[d],b).then(function(){a.goUp()})):e.isObject(c.additionalItems)?(a.goDown("["+d+"]"),g._validateObject(a,c.additionalItems,b).then(function(){a.goUp()})):void 0})}),f):void 0},a.prototype._recurseObject=function(a,c,d){var f=this,g=this.options.sync?null:b.resolve(),h=c.additionalProperties;(h===!0||void 0===h)&&(h={});var i=e.keys(c.properties||{}),j=e.keys(c.patternProperties||{});return e.forEach(d,function(b,d){var k=[];-1!==i.indexOf(d)&&k.push(c.properties[d]),j.forEach(function(a){e.getRegExp(a).test(d)===!0&&k.push(c.patternProperties[a])},this),0===k.length&&h!==!1&&k.push(h),k.forEach(function(c){this.options.sync?(a.goDown(d),this._validateObject(a,c,b),a.goUp()):g=g.then(function(){return a.goDown(d),f._validateObject(a,c,b).then(function(){a.goUp()})})},this)},this),this.options.sync?null: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()}),this.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()}),this.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(b,c){a.expect.boolean(c.__$compiled)},__$validated:function(b,c){a.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,c,d){if(e.isObject(d)){var f=[];return e.forEach(c.dependencies,function(b,c){void 0!==d[c]&&(e.isObject(b)?f.push(this._validateObject(a,b,d)):e.forEach(b,function(b){a.expect(void 0!==d[b],"OBJECT_DEPENDENCY_KEY",{missing:b,key:c})}))},this),this.options.sync?null:b.all(f)}},"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,c,d){if(!this.options.sync){var e=this;return b.all(c.allOf.map(function(b){return e._validateObject(a,b,d)}))}c.allOf.forEach(function(b){this._validateObject(a,b,d)},this)},anyOf:function(a,c,d){var e=0,f=[];if(this.options.sync)return c.anyOf.forEach(function(b){if(!(e>0)){var c=new h(a);this._validateObject(c,b,d),c.isValid()&&e++}},this),a.expect(e>=1,"ANY_OF_MISSING",{},0===e?f:null),void 0;var g=this,i=b.resolve();return c.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,c,d){function e(){a.expect(f>0,"ONE_OF_MISSING",{},0===f?g:null),a.expect(2>f,"ONE_OF_MULTIPLE")}var f=0,g=[];if(this.options.sync)return c.oneOf.forEach(function(b){var c=new h(a);this._validateObject(c,b,d),c.isValid()&&f++},this),e(),void 0;var i=this;return b.all(c.oneOf.map(function(b){var c=new h(a);return i._validateObject(c,b,d).then(function(){c.isValid()?f++:g.push(c)})})).then(e)},not:function(a,b,c){function d(){a.expect(!e.isValid(),"NOT_PASSED")}var e=new h(a);return this.options.sync?(this._validateObject(e,b.not,c),d(),void 0):this._validateObject(e,b.not,c).then(d)},definitions:function(){},format:function(a,c,d){var h;if("function"==typeof f[c.format])return a.expect(f[c.format](d,this),"FORMAT",{format:c.format,error:d}),void 0;{if(g[c.format].__$sync!==!0){var i=b.defer();try{h=g[c.format](d,i.callback),(b.is(h)||e.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=g[c.format](d),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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137256
2061
254
+ Addedbluebird@1.0.8(transitive)
+ Addedrequest@2.31.0(transitive)
- Removedbluebird@0.11.6(transitive)
- Removedrequest@2.30.0(transitive)
Updatedbluebird@~1.0.*
Updatedrequest@~2.31.*