Comparing version 2.4.9 to 2.4.10
{ | ||
"name": "z-schema", | ||
"description": "JSON schema validator", | ||
"version": "2.4.10", | ||
"dependencies": { | ||
"bluebird": ">=2.2.2", | ||
"request": ">=2.39.0" | ||
}, | ||
"homepage": "https://github.com/zaggino/z-schema", | ||
@@ -43,7 +48,2 @@ "keywords": [ | ||
], | ||
"version": "2.4.9", | ||
"dependencies": { | ||
"bluebird": ">=2.2.2", | ||
"request": ">=2.39.0" | ||
}, | ||
"devDependencies": { | ||
@@ -50,0 +50,0 @@ "grunt": "latest", |
@@ -253,4 +253,8 @@ # z-schema validator | ||
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) | ||
when true, uris 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) | ||
* strictEmails: ```true/false``` | ||
when true, emails are validated more strictly with a defined list of allowed top level domains, more info in [#48](https://github.com/zaggino/z-schema/issues/48) | ||
# Pull requests | ||
@@ -257,0 +261,0 @@ |
@@ -1,3 +0,3 @@ | ||
/*! z-schema version 2.4.7 */ | ||
!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)},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=Object.keys(a),f=Object.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):void(b&&c(f,function(a,c,g){return a?void b(a):void d(e._getRemoteSchemaCache[f]=g,f)}))},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 new Error(g?"Use .setRemoteReference to download references in sync mode: "+i:"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){if(!e.isString(a))return!0;var b=e.getRegExp("^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$").test(a);if(b){if(a.length>255)return!1;for(var c=a.split("."),d=0;d<c.length;d++)if(c[d].length>63)return!1}return b},"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,b);var d=new h;if(this.options.sync){if(this._compileSchema(d,a),this._validateSchema(d,a),this._lastError=d.toJSON(),d.isValid())return a;throw d.toError()}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()}),void d())}var f,g,h,i=this,j=b.defer(),k=[],l=[];return e(),j.promise.nodeify(c)},a.prototype.compileSchemasSync=function(a){function b(){d=0,a.forEach(function(b,g){try{e.compileSchema(b)}catch(h){return void(c=h)}d++,f.push(b),a.splice(g,1)})}var c,d,e=this,f=[];do b();while(d>0);if(0===a.length)return f;throw c},a.prototype.validateSchema=function(a,b){var c=new h;if(c.expect(e.isObject(a),"SCHEMA_TYPE_EXPECTED"),this.options.sync){if(this._validateSchema(c,a),this._lastError=c.toJSON(),c.isValid())return a;throw c.toError()}return 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})}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(),void d()):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)):void g.resolve(f._compileSchema(a,e).then(function(a){c.__remotes[d]=a}))}),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(){if(d.options.noTypeless===!0){if(void 0!==c.type){var b=[];Array.isArray(c.anyOf)&&(b=b.concat(c.anyOf)),Array.isArray(c.oneOf)&&(b=b.concat(c.oneOf)),Array.isArray(c.allOf)&&(b=b.concat(c.allOf)),b.forEach(function(a){a.type||(a.type=c.type)})}a.expect(void 0!==c.type||void 0!==c.anyOf||void 0!==c.oneOf||void 0!==c.not||void 0!==c.$ref,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"})}return 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}),void h.resolve()):void(c.__$downloadedFrom!==e.__$downloadedFrom?d.validate(c,e,function(b){b&&(a.errors=a.errors.concat(b.errors)),h.resolve()}):h.resolve())}),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?void d.forEach(function(b,d){a.goDown("["+d+"]"),this._validateObject(a,c.items,b),a.goUp()},this):(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?void 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):(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=Object.keys(c.properties||{}),j=Object.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){if(e.isObject(c)){var d=Object.keys(c).length;a.expect(d<=b.maxProperties,"OBJECT_PROPERTIES_MAXIMUM",{count:d,maximum:b.maxProperties})}},minProperties:function(a,b,c){if(e.isObject(c)){var d=Object.keys(c).length;a.expect(d>=b.minProperties,"OBJECT_PROPERTIES_MINIMUM",{count:d,minimum:b.minProperties})}},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=Object.keys(c),h=Object.keys(d),i=Object.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)}))}for(var f=c.allOf.length;f--&&this._validateObject(a,c.allOf[f],d););},anyOf:function(a,c,d){var e=[];if(this.options.sync){for(var f=!1,g=c.anyOf.length;g--&&!f;){var i=new h(a);e.push(i),f=this._validateObject(i,c.anyOf[g],d)}return void a.expect(f,"ANY_OF_MISSING",{},e)}var j=this,k=0,l=b.resolve();return c.anyOf.forEach(function(b){l=l.then(function(){if(!(k>0)){var c=new h(a);return j._validateObject(c,b,d).then(function(){c.isValid()?k++:e.push(c)})}})}),l.then(function(){a.expect(k>=1,"ANY_OF_MISSING",{},0===k?e: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){for(var i=c.oneOf.length;i--;){var j=new h(a);g.push(j),this._validateObject(j,c.oneOf[i],d)&&f++}return e()}var k=this;return b.all(c.oneOf.map(function(b){var c=new h(a);return k._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),void d()):this._validateObject(e,b.not,c).then(d)},definitions:function(){},format:function(a,c,d){var h;if("function"==typeof f[c.format])return void a.expect(f[c.format](d,this),"FORMAT",{format:c.format,error:d});{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}(); | ||
/*! z-schema version 2.4.9 */ | ||
!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)},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=Object.keys(a),f=Object.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):void(b&&c(f,function(a,c,g){return a?void b(a):void d(e._getRemoteSchemaCache[f]=g,f)}))},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 new Error(g?"Use .setRemoteReference to download references in sync mode: "+i:"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,d){("string"!=typeof d||0!==d.indexOf("__$"))&&(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){if(!e.isString(a))return!0;var b=e.getRegExp("^[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?(\\.[a-zA-Z](([-0-9a-zA-Z]+)?[0-9a-zA-Z])?)*$").test(a);if(b){if(a.length>255)return!1;for(var c=a.split("."),d=0;d<c.length;d++)if(c[d].length>63)return!1}return b},"host-name":function(){return f.hostname.apply(this,arguments)},ipv4:function(a){return"string"!=typeof a?!0:-1===a.indexOf(".")?!1: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,b);var d=new h;if(this.options.sync){if(this._compileSchema(d,a),this._validateSchema(d,a),this._lastError=d.toJSON(),d.isValid())return a;throw d.toError()}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()}),void d())}var f,g,h,i=this,j=b.defer(),k=[],l=[];return e(),j.promise.nodeify(c)},a.prototype.compileSchemasSync=function(a){function b(){d=0,a.forEach(function(b,g){try{e.compileSchema(b)}catch(h){return void(c=h)}d++,f.push(b),a.splice(g,1)})}var c,d,e=this,f=[];do b();while(d>0);if(0===a.length)return f;throw c},a.prototype.validateSchema=function(a,b){var c=new h;if(c.expect(e.isObject(a),"SCHEMA_TYPE_EXPECTED"),this.options.sync){if(this._validateSchema(c,a),this._lastError=c.toJSON(),c.isValid())return a;throw c.toError()}return this._validateSchema(c,a).then(function(){return c.toJSON()}).nodeify(b)},a.prototype._collectReferences=function k(a){var b=[];return e.isString(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 i.forEach(function(b){var d=b.$ref;d.length>1&&"#"===d.slice(-1)&&(d=d.substring(0,d.length-1)),b.__$refResolved||(b.__$refResolved=e.resolveSchemaQuery(b,c,d,!0,g.options.sync)||null),g.schemaCache&&g.schemaCache[d]&&(b.__$refResolved=g.schemaCache[d]),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}function f(){return j.map(function(b){return 0===b.indexOf("http:")||0===b.indexOf("https:")?g._downloadRemoteReferences(a,c,b.split("#")[0]):void 0})}var g=this;if("string"==typeof c){var h=e.getRemoteSchema(c);h?c=h:a.addError("SCHEMA_NOT_REACHABLE",{uri:c})}if(c.__$compiled)return c.id&&g.schemaCache&&(g.schemaCache[c.id]=c),this.options.sync?c:b.resolve(c);this._fixInnerReferences(c),this._fixOuterReferences(c);var i=this._collectReferences(c),j=e.uniq(i.map(function(a){return a.$ref}));return this.options.sync?(f(),void d()):b.all(f()).then(d)},a.prototype._fixInnerReferences=function l(a,b){b||(b=a),e.isString(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),e.isString(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)):void g.resolve(f._compileSchema(a,e).then(function(a){c.__remotes[d]=a}))}),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(){if(d.options.noTypeless===!0){if(void 0!==c.type){var b=[];Array.isArray(c.anyOf)&&(b=b.concat(c.anyOf)),Array.isArray(c.oneOf)&&(b=b.concat(c.oneOf)),Array.isArray(c.allOf)&&(b=b.concat(c.allOf)),b.forEach(function(a){a.type||(a.type=c.type)})}a.expect(void 0!==c.type||void 0!==c.anyOf||void 0!==c.oneOf||void 0!==c.not||void 0!==c.$ref,"KEYWORD_UNDEFINED_STRICT",{keyword:"type"})}return 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}),void h.resolve()):void(c.__$downloadedFrom!==e.__$downloadedFrom?d.validate(c,e,function(b){b&&(a.errors=a.errors.concat(b.errors)),h.resolve()}):h.resolve())}),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}if(a.expect.object(d),0===Object.keys(d).length)return this.options.sync?c.isValid():b.resolve(c);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?void d.forEach(function(b,d){a.goDown("["+d+"]"),this._validateObject(a,c.items,b),a.goUp()},this):(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?void 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):(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=Object.keys(c.properties||{}),j=Object.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){if(e.isObject(c)){var d=Object.keys(c).length;a.expect(d<=b.maxProperties,"OBJECT_PROPERTIES_MAXIMUM",{count:d,maximum:b.maxProperties})}},minProperties:function(a,b,c){if(e.isObject(c)){var d=Object.keys(c).length;a.expect(d>=b.minProperties,"OBJECT_PROPERTIES_MINIMUM",{count:d,minimum:b.minProperties})}},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=Object.keys(c),h=Object.keys(d),i=Object.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)}))}for(var f=c.allOf.length;f--&&this._validateObject(a,c.allOf[f],d););},anyOf:function(a,c,d){var e=[];if(this.options.sync){for(var f=!1,g=c.anyOf.length;g--&&!f;){var i=new h(a);e.push(i),f=this._validateObject(i,c.anyOf[g],d)}return void a.expect(f,"ANY_OF_MISSING",{},e)}var j=this,k=0,l=b.resolve();return c.anyOf.forEach(function(b){l=l.then(function(){if(!(k>0)){var c=new h(a);return j._validateObject(c,b,d).then(function(){c.isValid()?k++:e.push(c)})}})}),l.then(function(){a.expect(k>=1,"ANY_OF_MISSING",{},0===k?e: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){for(var i=c.oneOf.length;i--;){var j=new h(a);g.push(j),this._validateObject(j,c.oneOf[i],d)&&f++}return e()}var k=this;return b.all(c.oneOf.map(function(b){var c=new h(a);return k._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),void d()):this._validateObject(e,b.not,c).then(d)},definitions:function(){},format:function(a,c,d){var h;if("function"==typeof f[c.format])return void a.expect(f[c.format](d,this),"FORMAT",{format:c.format,error:d});{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
143500
2159
269