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

z-schema

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

z-schema - npm Package Compare versions

Comparing version 1.4.3 to 1.4.4

2

package.json

@@ -18,3 +18,3 @@ {

"files": ["src/zSchema.js", "src/zSchema.min.js", "LICENSE", "README.md"],
"version": "1.4.3",
"version": "1.4.4",
"dependencies": {

@@ -21,0 +21,0 @@ "q": ">= 0.9.6"

@@ -24,2 +24,2 @@ /*

*/
!function(){function e(e){this.options=i.defaults(e||{},{noExtraKeywords:!1,noZeroLengthStrings:!1,noTypeless:!1,forceAdditional:!1,forceProperties:!1,forceItems:!1,forceMaxLength:!1}),this.options.strict===!0&&(this.options.noExtraKeywords=!0,this.options.noZeroLengthStrings=!0,this.options.noTypeless=!0,this.options.forceAdditional=!0,this.options.forceProperties=!0,this.options.forceItems=!0,this.options.forceMaxLength=!0)}var t=require("q"),i={isBoolean:function(e){return"boolean"==typeof e},isString:function(e){return"string"==typeof e},isInteger:function(e){return this.isNumber(e)&&0===e%1},isNumber:function(e){return"number"==typeof e&&Number.isFinite(e)},isArray:function(e){return Array.isArray(e)},isObject:function(e){return"object"==typeof e&&e===Object(e)&&!Array.isArray(e)},isFunction:function(e){return"function"==typeof e},whatIs:function(e){if(void 0===e)return"undefined";if(null===e)return"null";if(this.isBoolean(e))return"boolean";if(this.isString(e))return"string";if(this.isArray(e))return"array";if(this.isInteger(e))return"integer";if(this.isNumber(e))return"number";if(this.isObject(e))return"object";if(this.isFunction(e))return"function";if(Number.isNaN(e))return"not-a-number";throw new Error("Utils.whatIs does not know what this is: "+e)},isUniqueArray:function(e){var t,i,n=e.length;for(t=0;n>t;t++)for(i=t+1;n>i;i++)if(this.areEqual(e[t],e[i]))return!1;return!0},keys:function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i);return t},forEach:function(e,t,n){if(Array.isArray(e))return e.forEach(t,n);if(i.isObject(e))for(var r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r)},defaults:function(e,t){return i.forEach(t,function(t,i){void 0===e[i]&&(e[i]=t)}),e},uniq:function(e){var t=[];return e.forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),t},difference:function(e,t){var i=[];return e.forEach(function(e){-1===t.indexOf(e)&&i.push(e)}),i},areEqual:function(e,t){if(e===t)return!0;var i,n;if(this.isArray(e)&&this.isArray(t)){if(e.length!==t.length)return!1;for(n=e.length,i=0;n>i;i++)if(!this.areEqual(e[i],t[i]))return!1;return!0}if(this.isObject(e)&&this.isObject(t)){var r=this.keys(e),o=this.keys(t);if(!this.areEqual(r,o))return!1;for(n=r.length,i=0;n>i;i++)if(!this.areEqual(e[r[i]],t[r[i]]))return!1;return!0}return!1},decodeJSONPointer:function(e){return decodeURIComponent(e).replace(/~[0-1]/g,function(e){return"~1"===e?"/":"~"})},_getRegExpCache:{},getRegExp:function(e){return this._getRegExpCache[e]||(this._getRegExpCache[e]=new RegExp(e)),this._getRegExpCache[e]},_getRemoteSchemaCache:{},getRemoteSchema:function(e,t){function i(e){var i=JSON.parse(e);i.id||(i.id=n),i.$schema||(i.$schema=n),t(void 0,i)}var n=e.split("#")[0];if(this._getRemoteSchemaCache[n])return i(this._getRemoteSchemaCache[n]),void 0;var r=this,o=require("http");o.get(n,function(e){var t="";e.on("data",function(e){t+=e}),e.on("end",function(){i(r._getRemoteSchemaCache[n]=t)})}).on("error",function(e){t(e)})},resolveSchemaQuery:function(e,t,n){if(r.expect.string(n),"#"===n)return t;var o=null,a=n.split("#")[0],s=n.split("#")[1];if(0===n.indexOf("http:")||0===n.indexOf("https:")){if(!t.__remotes||!t.__remotes[a])throw new Error("Remote is not downloaded: "+a);o=t.__remotes[a]}if(o=o||t,s)for(var c=("#"+s).split("/");c.length>0;){var u=i.decodeJSONPointer(c.shift());-1===u.indexOf("#")?o=o[u]:"#"!==u&&(o=i.resolveSchemaId(o,u))}if(!o)throw new Error("Could not resolve schema reference: "+n);return o},resolveSchemaId:function(e,t){if(this.isObject(e)||this.isArray(e)){if(e.id===t)return e;var n=null;return i.forEach(e,function(e){n||(n=i.resolveSchemaId(e,t))}),n}}},n={date:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$"),n=t.exec(e);if(null===n)return!1;var r=n[2],o=n[3];return"01">r||r>"12"||"01">o||o>"31"?!1:!0},"date-time":function(e){if(!i.isString(e))return!0;if(!i.isString(e))return!1;var t=e.toLowerCase().split("t");if(!n.date(t[0]))return!1;var r=i.getRegExp("^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$").exec(t[1]);if(null===r)return!1;var o=r[1],a=r[2],s=r[3];return o>"23"||a>"59"||s>"59"?!1:!0},email:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^[a-zA-Z0-9+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$");return t.test(e)},hostname:function(e){if(!i.isString(e))return!0;if(-1===e.indexOf("."))return!1;var t=i.getRegExp("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$");return t.test(e)},ipv4:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");return t.test(e)},ipv6:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$");return t.test(e)},uri:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:]])?");return t.test(e)}},r={getMessage:function(e){var t=arguments,i=this.messages[e]||e;return i.replace(/{([1-9])}/g,function(e,i){return t[i]})},messages:{TYPE_EXPECTED:'"{1}" expected but "{2}" found.',KEYWORD_TYPE_EXPECTED:'Keyword "{1}" is expected to be type of "{2}".',KEYWORD_MUST_BE:'Keyword "{1}" must be {2}.',IF_ONE_PRESENT_THEN_ALSO_OTHER:'If "{1}" is present, then "{2}" must also be present.',IS_NOT_REGEXP:"Following string is not valid regExp: {1}.",KEYWORD_SCHEMA_EXPECTED:'Keyword "{1}" is expected to be a valid schema.',KEYWORD_SCHEMA_EXPECTED_IN_ARRAY:'Keyword "{1}" is expected to be an array of valid schemas.',KEYWORD_SCHEMA_EXPECTED_IN_OBJECT:'Keyword "{1}" is expected to be an object of valid schemas.',E001:"Some properties are not expected to appear on this object ({1}).",E002:'Instance failed to validate against schemas in "{1}".',E003:'Value of instance must be equal to one of the elements in "enum". ({1})',E004:'"{1}" is expected to be of type {2}. ({3})',EC01:'Keyword "{1}" must always be defined when using strict mode.',EC02:'Keyword "{1}" is not expected to appear in the schema.'},fail:function(e){throw this.messages[e]&&(e=this.getMessage.apply(this,arguments)),new Error(e)},expect:{"boolean":function(e){if(!i.isBoolean(e))throw new Error(r.getMessage("TYPE_EXPECTED","boolean",i.whatIs(e)))},string:function(e){if(!i.isString(e))throw new Error(r.getMessage("TYPE_EXPECTED","string",i.whatIs(e)))},callable:function(e){if(!i.isFunction(e))throw new Error(r.getMessage("TYPE_EXPECTED","function",i.whatIs(e)))},object:function(e){if(!i.isObject(e))throw new Error(r.getMessage("TYPE_EXPECTED","object",i.whatIs(e)))}}},o=function(e){e&&i.forEach(e,function(e,t){this[t]=e},this),this.errors=[],this.warnings=[],this.path=[]};o.prototype={addWarning:function(e){return this.warnings.push({message:e,path:"#/"+this.path.join("/")}),!0},addError:function(e){return this.errors.push({message:e,path:"#/"+this.path.join("/")}),!1},expect:function(e){return e?!0:(Array.prototype.shift.call(arguments),this.addError(r.getMessage.apply(r,arguments)),!1)},isValid:function(){return 0===this.errors.length},toJSON:function(){return{valid:0===this.errors.length,errors:this.errors,warnings:this.warnings}},goDown:function(e){this.path.push(e)},goUp:function(){this.path.pop()}},e.validate=function(){if(!this._defaultInstance){var e=this;this._defaultInstance=new e}return this._defaultInstance.validate.apply(this._defaultInstance,arguments)},e.registerFormat=function(e,t){r.expect.string(e),r.expect.callable(t),n[e]&&r.fail("CANNOT OVERRIDE EXISTING VALIDATOR FOR "+e),n[e]=t},e.setRemoteReference=function(e,t){r.expect.string(t),i._getRemoteSchemaCache[e]=t},e.prototype.validate=function(e,t,i){var n=this,r=new o;this._compileSchema(r,t).then(function(t){return r.isValid()?(n._validateSchema(r,t),r.isValid()?(n._validateObject(r,t,e),i(r.toJSON()),void 0):(i(r.toJSON()),void 0)):(i(r.toJSON()),void 0)}).fail(function(e){throw console.error(e),e}).done()},e.prototype.compileSchema=function(e,t){var i=this,n=new o;this._compileSchema(n,e).then(function(e){i._validateSchema(n,e),n.isValid()?t(void 0,e):t(n.toJSON().errors,void 0)}).done()},e.prototype.validateWithCompiled=function(e,t,i){t.__compiled!==!0&&console.warn("Schema is not compiled and might provide unexpected results.");var n=new o;this._validateObject(n,t,e);var r=n.toJSON();return i&&(n.isValid()?i(void 0,!0,r):i(r.errors,!1,r)),r},e.prototype._compileSchema=function(e,n){if(n.__compiled)return t(n);n.__compiled=!0,this._fixReferences(n);var r=i.uniq(this._collectReferences(n)),o=this,a=t();r.forEach(function(t){0===t.indexOf(n.$schema)||0!==t.indexOf("http:")&&0!==t.indexOf("https:")||(a=a.then(function(){return o._downloadRemoteReferences(e,n,t.split("#")[0])}))},this);var s=t.defer();return a.then(function(){s.resolve(n)}).done(),s.promise},e.prototype._collectReferences=function c(e){var t=[];return e.$ref&&t.push(e.$ref),i.forEach(e,function(e){(i.isObject(e)||i.isArray(e))&&(t=t.concat(c(e)))},this),t},e.prototype._fixReferences=function u(e,t){t=t||[],i.isString(e.id)&&t.push(e.id),e.$ref&&t.length>0&&(e.$ref=0===e.$ref.indexOf("#")?t.join("").split("#")[0]+e.$ref:t.join("")+e.$ref),i.forEach(e,function(e){(i.isObject(e)||i.isArray(e))&&u(e,t)},this),i.isString(e.id)&&t.pop()},e.prototype._downloadRemoteReferences=function(e,n,r){var o=this,a=t.defer();return i.getRemoteSchema(r,function(t,i){return t?(t.description="Connection failed to: "+r,e.addError(t),console.error(t.description),a.resolve()):(n.__remotes||(n.__remotes={}),o._compileSchema(e,i).then(function(e){n.__remotes[r]=e,a.resolve()}).done(),void 0)}),a.promise},e.prototype._validateSchema=function(e,t){return this.options.noTypeless===!0&&e.expect(void 0!==t.type,"EC01","type"),i.forEach(t,function(i,n){void 0!==a[n]?a[n].call(this,e,t):this.options.noExtraKeywords===!0?e.expect(!1,"EC02",n):e.addWarning('Unknown key "'+n+'" found in schema.')},this),e.isValid()},e.prototype._validateObject=function(e,t,n){r.expect.object(t);var o=!1;e.rootSchema||(e.rootSchema=t,o=!0);for(var a=99;t.$ref&&a>0;)t=i.resolveSchemaQuery(t,e.rootSchema,t.$ref),a--;return i.forEach(t,function(i,r){void 0!==s[r]&&s[r].call(this,e,t,n)},this),i.isArray(n)?this._recurseArray(e,t,n):i.isObject(n)&&this._recurseObject(e,t,n),o&&delete e.rootSchema,e.isValid()},e.prototype._recurseArray=function(e,t,n){i.isObject(t.items)&&n.forEach(function(i,n){e.goDown("["+n+"]"),this._validateObject(e,t.items,i),e.goUp()},this),i.isArray(t.items)&&n.forEach(function(n,r){r<t.items.length?(e.goDown("["+r+"]"),this._validateObject(e,t.items[r],n),e.goUp()):i.isObject(t.additionalItems)&&(e.goDown("["+r+"]"),this._validateObject(e,t.additionalItems,n),e.goUp())},this)},e.prototype._recurseObject=function(e,t,n){var r=t.additionalProperties;(r===!0||void 0===r)&&(r={});var o=i.keys(t.properties||{}),a=i.keys(t.patternProperties||{});i.forEach(n,function(n,s){var c=[];-1!==o.indexOf(s)&&c.push(t.properties[s]),a.forEach(function(e){i.getRegExp(e).test(s)===!0&&c.push(t.patternProperties[e])},this),0===c.length&&r!==!1&&c.push(r),c.forEach(function(t){e.goDown(s),this._validateObject(e,t,n),e.goUp()},this)},this)};var a={$ref:function(e,t){e.expect(i.isString(t.$ref),"KEYWORD_TYPE_EXPECTED","$ref","string")},$schema:function(e,t){e.expect(i.isString(t.$schema),"KEYWORD_TYPE_EXPECTED","$schema","string")},multipleOf:function(e,t){var n=e.expect(i.isNumber(t.multipleOf),"KEYWORD_TYPE_EXPECTED","multipleOf","number");n&&e.expect(t.multipleOf>0,"KEYWORD_MUST_BE","multipleOf","strictly greater than 0")},maximum:function(e,t){e.expect(i.isNumber(t.maximum),"KEYWORD_TYPE_EXPECTED","maximum","number")},exclusiveMaximum:function(e,t){var n=e.expect(i.isBoolean(t.exclusiveMaximum),"KEYWORD_TYPE_EXPECTED","exclusiveMaximum","boolean");n&&e.expect(void 0!==t.maximum,"IF_ONE_PRESENT_THEN_ALSO_OTHER","exclusiveMaximum","maximum")},minimum:function(e,t){e.expect(i.isNumber(t.minimum),"KEYWORD_TYPE_EXPECTED","minimum","number")},exclusiveMinimum:function(e,t){var n=e.expect(i.isBoolean(t.exclusiveMinimum),"KEYWORD_TYPE_EXPECTED","exclusiveMinimum","boolean");n&&e.expect(void 0!==t.minimum,"IF_ONE_PRESENT_THEN_ALSO_OTHER","exclusiveMinimum","minimum")},maxLength:function(e,t){var n=e.expect(i.isInteger(t.maxLength),"KEYWORD_TYPE_EXPECTED","maxLength","integer");n&&e.expect(t.maxLength>=0,"KEYWORD_MUST_BE","maxLength","greater than, or equal to 0")},minLength:function(e,t){var n=e.expect(i.isInteger(t.minLength),"KEYWORD_TYPE_EXPECTED","minLength","integer");n&&e.expect(t.minLength>=0,"KEYWORD_MUST_BE","minLength","greater than, or equal to 0")},pattern:function(e,t){var n=e.expect(i.isString(t.pattern),"KEYWORD_TYPE_EXPECTED","pattern","string");if(n)try{i.getRegExp(t.pattern)}catch(r){e.addError("IS_NOT_REGEXP",t.pattern)}},additionalItems:function(e,t){var n=i.isBoolean(t.additionalItems),r=i.isObject(t.additionalItems),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","additionalItems",["boolean","object"]);o&&r&&(e.goDown("additionalItems"),this._validateSchema(e,t.additionalItems),e.goUp())},items:function(e,t){var n=i.isArray(t.items),r=i.isObject(t.items),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","items",["array","object"]);o&&(r?(e.goDown("items"),this._validateSchema(e,t.items),e.goUp()):n&&t.items.forEach(function(t,i){e.goDown("items["+i+"]"),this._validateSchema(e,t),e.goUp()},this),this.options.forceAdditional===!0&&e.expect(void 0!==t.additionalItems,"EC01","additionalItems"))},maxItems:function(e,t){var n=e.expect(i.isInteger(t.maxItems),"KEYWORD_TYPE_EXPECTED","maxItems","integer");n&&e.expect(t.maxItems>=0,"KEYWORD_MUST_BE","maxItems","greater than, or equal to 0")},minItems:function(e,t){var n=e.expect(i.isInteger(t.minItems),"KEYWORD_TYPE_EXPECTED","minItems","integer");n&&e.expect(t.minItems>=0,"KEYWORD_MUST_BE","minItems","greater than, or equal to 0")},uniqueItems:function(e,t){e.expect(i.isBoolean(t.uniqueItems),"KEYWORD_TYPE_EXPECTED","uniqueItems","boolean")},maxProperties:function(e,t){var n=e.expect(i.isInteger(t.maxProperties),"KEYWORD_TYPE_EXPECTED","maxProperties","integer");n&&e.expect(t.maxProperties>=0,"KEYWORD_MUST_BE","maxProperties","greater than, or equal to 0")},minProperties:function(e,t){var n=e.expect(i.isInteger(t.minProperties),"KEYWORD_TYPE_EXPECTED","minProperties","integer");n&&e.expect(t.minProperties>=0,"KEYWORD_MUST_BE","minProperties","greater than, or equal to 0")},required:function(e,t){var n;n=e.expect(i.isArray(t.required),"KEYWORD_TYPE_EXPECTED","required","array"),n&&(n=e.expect(t.required.length>0,"KEYWORD_MUST_BE","required","an array with at least one element."),n&&(t.required.forEach(function(t){e.expect(i.isString(t),'Each element of "required" array must be a string.')},this),e.expect(i.isUniqueArray(t.required),'Elements in "required" array must be unique.')))},additionalProperties:function(e,t){var n=i.isBoolean(t.additionalProperties),r=i.isObject(t.additionalProperties),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","additionalProperties",["boolean","object"]);o&&r&&(e.goDown("additionalProperties"),this._validateSchema(e,t.additionalProperties),e.goUp())},properties:function(e,t){var n=e.expect(i.isObject(t.properties),"KEYWORD_TYPE_EXPECTED","properties","object");n&&(i.forEach(t.properties,function(t,i){e.goDown("properties["+i+"]"),this._validateSchema(e,t),e.goUp()},this),this.options.forceAdditional===!0&&e.expect(void 0!==t.additionalProperties,"EC01","additionalProperties"))},patternProperties:function(e,t){var n=e.expect(i.isObject(t.patternProperties),"KEYWORD_TYPE_EXPECTED","patternProperties","object");n&&i.forEach(t.patternProperties,function(t,n){try{i.getRegExp(n)}catch(r){e.addError("IS_NOT_REGEXP",n)}e.goDown("patternProperties["+n+"]"),this._validateSchema(e,t),e.goUp()},this)},dependencies:function(e,t){var n=e.expect(i.isObject(t.dependencies),"KEYWORD_TYPE_EXPECTED","dependencies","object");n&&i.forEach(t.dependencies,function(t,n){var r=i.isObject(t),o=i.isArray(t);e.expect(r||o,'Each value of "dependencies" must be either an object or an array.'),r?(e.goDown("dependencies["+n+"]"),this._validateSchema(e,t),e.goUp()):o&&(e.expect(t.length>0,'"dependencies" array must have at least one element.'),t.forEach(function(t){e.expect(i.isString(t),'Each element of "dependencies" array must be a string.')},this),e.expect(i.isUniqueArray(t),'Elements in "dependencies" array must be unique.'))},this)},"enum":function(e,t){var n;n=e.expect(i.isArray(t.enum),"KEYWORD_TYPE_EXPECTED","enum","array"),n&&(n=e.expect(t.enum.length>0,"KEYWORD_MUST_BE","enum","an array with at least one element."),n&&(n=e.expect(i.isUniqueArray(t.enum),'Elements in "enum" array must be unique.')))},type:function(e,t){var n,r=["array","boolean","integer","number","null","object","string"],o=r.join(","),a=i.isString(t.type),s=i.isArray(t.type);n=e.expect(a||s,"KEYWORD_TYPE_EXPECTED","type",["string","array"]),n&&(s?(t.type.forEach(function(t){e.expect(-1!==r.indexOf(t),'"type" array must consist of strings: '+o+".")},this),e.expect(i.isUniqueArray(t.type),'Elements in "type" array must be unique.')):e.expect(-1!==r.indexOf(t.type),'"type" string must be one of '+o+"."),this.options.noZeroLengthStrings===!0&&("string"===t.type||s&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&(t.minLength=1),this.options.forceProperties===!0&&("object"===t.type||s&&-1!==t.type.indexOf("object"))&&e.expect(void 0!==t.properties||void 0!==t.patternProperties,"EC01","properties"),this.options.forceItems===!0&&("array"===t.type||s&&-1!==t.type.indexOf("array"))&&e.expect(void 0!==t.items,"EC01","items"),this.options.forceMaxLength===!0&&("string"===t.type||s&&-1!==t.type.indexOf("string"))&&e.expect(void 0!==t.maxLength||void 0!==t.format||void 0!==t.enum,"EC01","maxLength"))},allOf:function(e,t){var n;n=e.expect(i.isArray(t.allOf),"KEYWORD_TYPE_EXPECTED","allOf","array"),n&&(n=e.expect(t.allOf.length>0,"KEYWORD_MUST_BE","allOf","an array with at least one element."),n&&t.allOf.forEach(function(t,i){e.goDown("allOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},anyOf:function(e,t){var n;n=e.expect(i.isArray(t.anyOf),"KEYWORD_TYPE_EXPECTED","anyOf","array"),n&&(n=e.expect(t.anyOf.length>0,"KEYWORD_MUST_BE","anyOf","an array with at least one element."),n&&t.anyOf.forEach(function(t,i){e.goDown("anyOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},oneOf:function(e,t){var n;n=e.expect(i.isArray(t.oneOf),"KEYWORD_TYPE_EXPECTED","oneOf","array"),n&&(n=e.expect(t.oneOf.length>0,"KEYWORD_MUST_BE","oneOf","an array with at least one element."),n&&t.oneOf.forEach(function(t,i){e.goDown("oneOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},not:function(e,t){var n;n=e.expect(i.isObject(t.not),"KEYWORD_TYPE_EXPECTED","not","object"),n&&(e.goDown("not"),this._validateSchema(e,t.not),e.goUp())},definitions:function(e,t){var n;n=e.expect(i.isObject(t.definitions),"KEYWORD_TYPE_EXPECTED","definitions","object"),n&&i.forEach(t.definitions,function(t,i){e.goDown("definitions["+i+"]"),this._validateSchema(e,t),e.goUp()},this)},format:function(e,t){var r;r=e.expect(i.isString(t.format),"KEYWORD_TYPE_EXPECTED","format","string"),r&&(r=e.expect(i.isFunction(n[t.format]),"There is no validator function defined for format. ("+t.format+")"))},id:function(e,t){e.expect(i.isString(t.id),"KEYWORD_TYPE_EXPECTED","id","string")},description:function(e,t){e.expect(i.isString(t.description),"KEYWORD_TYPE_EXPECTED","description","string")},"default":function(){},__compiled:function(e,t){r.expect.boolean(t.__compiled)}},s={multipleOf:function(e,t,n){if(i.isNumber(n)){var r="integer"===i.whatIs(n/t.multipleOf);e.expect(r,n+" is not a multiple of "+t.multipleOf)}},maximum:function(e,t,n){i.isNumber(n)&&(t.exclusiveMaximum!==!0?e.expect(n<=t.maximum,n+" is bigger than maximum of "+t.maximum):e.expect(n<t.maximum,n+" is bigger or equal to the exclusiveMaximum of "+t.maximum))},exclusiveMaximum:function(){},minimum:function(e,t,n){i.isNumber(n)&&(t.exclusiveMinimum!==!0?e.expect(n>=t.minimum,n+" is less than minimum of "+t.minimum):e.expect(n>t.minimum,n+" is less or equal to the exclusiveMinimum of "+t.minimum))},exclusiveMinimum:function(){},maxLength:function(e,t,n){i.isString(n)&&e.expect(n.length<=t.maxLength,n+" is longer than maxLength of "+t.maxLength)},minLength:function(e,t,n){i.isString(n)&&e.expect(n.length>=t.minLength,n+" is shorter than minLength of "+t.minLength)},pattern:function(e,t,n){i.isString(n)&&e.expect(i.getRegExp(t.pattern).test(n),n+" did not pass pattern validation to "+t.pattern)},additionalItems:function(e,t,n){i.isArray(n)&&t.additionalItems===!1&&i.isArray(t.items)&&e.expect(n.length<=t.items.length,"")},items:function(){},maxItems:function(e,t,n){i.isArray(n)&&e.expect(n.length<=t.maxItems,"Array has more items than maxItems of "+t.maxItems)},minItems:function(e,t,n){i.isArray(n)&&e.expect(n.length>=t.minItems,"Array has less items than minItems of "+t.minItems)},uniqueItems:function(e,t,n){i.isArray(n)&&t.uniqueItems===!0&&e.expect(i.isUniqueArray(n),"Items in this array are not unique as they should be.")},maxProperties:function(e,t,n){i.isObject(n)&&e.expect(i.keys(n).length<=t.maxProperties,"Object has more properties than maxProperties of "+t.maxProperties)},minProperties:function(e,t,n){i.isObject(n)&&e.expect(i.keys(n).length>=t.minProperties,"Object has less properties than minProperties of "+t.minProperties)},required:function(e,t,n){i.isObject(n)&&t.required.forEach(function(t){e.expect(void 0!==n[t],'Object is required to have a property "'+t+'"')})},additionalProperties:function(e,t){return void 0===t.properties&&void 0===t.patternProperties?s.properties.apply(this,arguments):void 0},properties:function(e,t,n){if(i.isObject(n)){var r=void 0!==t.properties?t.properties:{},o=void 0!==t.patternProperties?t.patternProperties:{};if(t.additionalProperties===!1){var a=i.keys(n),s=i.keys(r),c=i.keys(o);a=i.difference(a,s),c.forEach(function(e){for(var t=i.getRegExp(e),n=a.length-1;n>=0;n--)t.test(a[n])===!0&&a.splice(n,1)},this),e.expect(0===a.length,"E001",a.join(","))}}},patternProperties:function(e,t){return void 0===t.properties?s.properties.apply(this,arguments):void 0},dependencies:function(e,t,n){i.isObject(n)&&i.forEach(t.dependencies,function(t,r){void 0!==n[r]&&(i.isObject(t)?this._validateObject(e,t,n):i.forEach(t,function(t){e.expect(void 0!==n[t],"Object MUST include property from dependencies ("+t+").")},this))},this)},"enum":function(e,t,n){for(var r=!1,o=0,a=t.enum.length;a>o;o++)if(i.areEqual(n,t.enum[o])){r=!0;break}e.expect(r,"E003",n)},type:function(e,t,n){var r=i.whatIs(n);if(i.isString(t.type))e.expect(r===t.type||"integer"===r&&"number"===t.type,"E004",n,t.type,r);else{var o=-1!==t.type.indexOf(r),a="integer"===r&&-1!==t.type.indexOf("number");e.expect(o||a,n+" is expected to be one of "+t.type)}},allOf:function(e,t,i){t.allOf.forEach(function(t){this._validateObject(e,t,i)},this)},anyOf:function(e,t,i){for(var n=0,r=0,a=t.anyOf.length;a>r;r++){var s=new o(e);if(this._validateObject(s,t.anyOf[r],i),s.isValid()){n++;break}}e.expect(n>=1,"E002","anyOf")},oneOf:function(e,t,i){for(var n=0,r=0,a=t.oneOf.length;a>r;r++){var s=new o(e);this._validateObject(s,t.oneOf[r],i),s.isValid()&&n++}e.expect(n>0,"E002","oneOf"),e.expect(2>n,'Instance validated against more than one schema in "oneOf".')},not:function(e,t,i){var n=new o(e);this._validateObject(n,t.not,i),e.expect(!n.isValid(),'Instance validated against a schema in "not"')},definitions:function(){},format:function(e,t,i){e.expect(n[t.format](i),"Instance did not pass format validation. ("+t.format+")")}};module.exports=e}();
!function(){function e(e){this.options=i.defaults(e||{},{noExtraKeywords:!1,noZeroLengthStrings:!1,noTypeless:!1,forceAdditional:!1,forceProperties:!1,forceItems:!1,forceMaxLength:!1}),this.options.strict===!0&&(this.options.noExtraKeywords=!0,this.options.noZeroLengthStrings=!0,this.options.noTypeless=!0,this.options.forceAdditional=!0,this.options.forceProperties=!0,this.options.forceItems=!0,this.options.forceMaxLength=!0)}var t=require("q"),i={isBoolean:function(e){return"boolean"==typeof e},isString:function(e){return"string"==typeof e},isInteger:function(e){return this.isNumber(e)&&0===e%1},isNumber:function(e){return"number"==typeof e&&Number.isFinite(e)},isArray:function(e){return Array.isArray(e)},isObject:function(e){return"object"==typeof e&&e===Object(e)&&!Array.isArray(e)},isFunction:function(e){return"function"==typeof e},whatIs:function(e){if(void 0===e)return"undefined";if(null===e)return"null";if(this.isBoolean(e))return"boolean";if(this.isString(e))return"string";if(this.isArray(e))return"array";if(this.isInteger(e))return"integer";if(this.isNumber(e))return"number";if(this.isObject(e))return"object";if(this.isFunction(e))return"function";if(Number.isNaN(e))return"not-a-number";throw new Error("Utils.whatIs does not know what this is: "+e)},isUniqueArray:function(e){var t,i,n=e.length;for(t=0;n>t;t++)for(i=t+1;n>i;i++)if(this.areEqual(e[t],e[i]))return!1;return!0},keys:function(e){var t=[];for(var i in e)e.hasOwnProperty(i)&&t.push(i);return t},forEach:function(e,t,n){if(Array.isArray(e))return e.forEach(t,n);if(i.isObject(e))for(var r in e)e.hasOwnProperty(r)&&t.call(n,e[r],r)},defaults:function(e,t){return i.forEach(t,function(t,i){void 0===e[i]&&(e[i]=t)}),e},uniq:function(e){var t=[];return e.forEach(function(e){-1===t.indexOf(e)&&t.push(e)}),t},difference:function(e,t){var i=[];return e.forEach(function(e){-1===t.indexOf(e)&&i.push(e)}),i},areEqual:function(e,t){if(e===t)return!0;var i,n;if(this.isArray(e)&&this.isArray(t)){if(e.length!==t.length)return!1;for(n=e.length,i=0;n>i;i++)if(!this.areEqual(e[i],t[i]))return!1;return!0}if(this.isObject(e)&&this.isObject(t)){var r=this.keys(e),o=this.keys(t);if(!this.areEqual(r,o))return!1;for(n=r.length,i=0;n>i;i++)if(!this.areEqual(e[r[i]],t[r[i]]))return!1;return!0}return!1},decodeJSONPointer:function(e){return decodeURIComponent(e).replace(/~[0-1]/g,function(e){return"~1"===e?"/":"~"})},_getRegExpCache:{},getRegExp:function(e){return this._getRegExpCache[e]||(this._getRegExpCache[e]=new RegExp(e)),this._getRegExpCache[e]},_getRemoteSchemaCache:{},getRemoteSchema:function(e,t){function i(e){var i=JSON.parse(e);i.id||(i.id=n),i.$schema||(i.$schema=n),t(void 0,i)}var n=e.split("#")[0];if(this._getRemoteSchemaCache[n])return i(this._getRemoteSchemaCache[n]),void 0;var r=this,o=require("http");o.get(n,function(e){var t="";e.on("data",function(e){t+=e}),e.on("end",function(){i(r._getRemoteSchemaCache[n]=t)})}).on("error",function(e){t(e)})},resolveSchemaQuery:function(e,t,n){if(r.expect.string(n),"#"===n)return t;var o=null,a=n.split("#")[0],s=n.split("#")[1];if(0===n.indexOf("http:")||0===n.indexOf("https:")){if(!t.__remotes||!t.__remotes[a])throw new Error("Remote is not downloaded: "+a);o=t.__remotes[a]}if(o=o||t,s)for(var c=("#"+s).split("/");c.length>0;){var u=i.decodeJSONPointer(c.shift());-1===u.indexOf("#")?o=o[u]:"#"!==u&&(o=i.resolveSchemaId(o,u))}if(!o)throw new Error("Could not resolve schema reference: "+n);return o},resolveSchemaId:function(e,t){if(this.isObject(e)||this.isArray(e)){if(e.id===t)return e;var n=null;return i.forEach(e,function(e){n||(n=i.resolveSchemaId(e,t))}),n}}},n={date:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^([0-9]{4})-([0-9]{2})-([0-9]{2})$"),n=t.exec(e);if(null===n)return!1;var r=n[2],o=n[3];return"01">r||r>"12"||"01">o||o>"31"?!1:!0},"date-time":function(e){if(!i.isString(e))return!0;if(!i.isString(e))return!1;var t=e.toLowerCase().split("t");if(!n.date(t[0]))return!1;var r=i.getRegExp("^([0-9]{2}):([0-9]{2}):([0-9]{2})(.[0-9]+)?(z|([+-][0-9]{2}:[0-9]{2}))$").exec(t[1]);if(null===r)return!1;var o=r[1],a=r[2],s=r[3];return o>"23"||a>"59"||s>"59"?!1:!0},email:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^[a-zA-Z0-9+&*-]+(?:.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,7}$");return t.test(e)},hostname:function(e){if(!i.isString(e))return!0;if(-1===e.indexOf("."))return!1;var t=i.getRegExp("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]).)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$");return t.test(e)},ipv4:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");return t.test(e)},ipv6:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*$");return t.test(e)},uri:function(e){if(!i.isString(e))return!0;var t=i.getRegExp("((((https?|ftps?|gopher|telnet|nntp)://)|(mailto:|news:))(%[0-9A-Fa-f]{2}|[-()_.!~*';/?:@&=+$,A-Za-z0-9])+)([).!';/?:,][[:blank:]])?");return t.test(e)}},r={getMessage:function(e){var t=arguments,i=this.messages[e]||e;return i.replace(/{([1-9])}/g,function(e,i){return t[i]})},messages:{TYPE_EXPECTED:'"{1}" expected but "{2}" found.',KEYWORD_TYPE_EXPECTED:'Keyword "{1}" is expected to be type of "{2}".',KEYWORD_MUST_BE:'Keyword "{1}" must be {2}.',IF_ONE_PRESENT_THEN_ALSO_OTHER:'If "{1}" is present, then "{2}" must also be present.',IS_NOT_REGEXP:"Following string is not valid regExp: {1}.",KEYWORD_SCHEMA_EXPECTED:'Keyword "{1}" is expected to be a valid schema.',KEYWORD_SCHEMA_EXPECTED_IN_ARRAY:'Keyword "{1}" is expected to be an array of valid schemas.',KEYWORD_SCHEMA_EXPECTED_IN_OBJECT:'Keyword "{1}" is expected to be an object of valid schemas.',E001:"Some properties are not expected to appear on this object ({1}).",E002:'Instance failed to validate against schemas in "{1}".',E003:'Value of instance must be equal to one of the elements in "enum". ({1})',E004:'"{1}" is expected to be of type {2}. ({3})',E005:"Instance did not pass format validation. ({1}, {2})",E006:'Instance validated against more than one schema in "{1}".',EC01:'Keyword "{1}" must always be defined when using strict mode.',EC02:'Keyword "{1}" is not expected to appear in the schema.'},fail:function(e){throw this.messages[e]&&(e=this.getMessage.apply(this,arguments)),new Error(e)},expect:{"boolean":function(e){if(!i.isBoolean(e))throw new Error(r.getMessage("TYPE_EXPECTED","boolean",i.whatIs(e)))},string:function(e){if(!i.isString(e))throw new Error(r.getMessage("TYPE_EXPECTED","string",i.whatIs(e)))},callable:function(e){if(!i.isFunction(e))throw new Error(r.getMessage("TYPE_EXPECTED","function",i.whatIs(e)))},object:function(e){if(!i.isObject(e))throw new Error(r.getMessage("TYPE_EXPECTED","object",i.whatIs(e)))}}},o=function(e){e&&i.forEach(e,function(e,t){this[t]=e},this),this.errors=[],this.warnings=[],this.path=[]};o.prototype={addWarning:function(e){return this.warnings.push({message:e,path:"#/"+this.path.join("/")}),!0},addSubReports:function(e,t){this.goDown(e),t.forEach(function(e){e.errors.forEach(function(e){this.addError(e.message)},this)},this),this.goUp()},addError:function(e){return this.errors.push({message:e,path:"#/"+this.path.join("/")}),!1},expect:function(e){return e?!0:(Array.prototype.shift.call(arguments),this.addError(r.getMessage.apply(r,arguments)),!1)},isValid:function(){return 0===this.errors.length},toJSON:function(){return{valid:0===this.errors.length,errors:this.errors,warnings:this.warnings}},goDown:function(e){this.path.push(e)},goUp:function(){this.path.pop()}},e.validate=function(){if(!this._defaultInstance){var e=this;this._defaultInstance=new e}return this._defaultInstance.validate.apply(this._defaultInstance,arguments)},e.registerFormat=function(e,t){r.expect.string(e),r.expect.callable(t),n[e]&&r.fail("CANNOT OVERRIDE EXISTING VALIDATOR FOR "+e),n[e]=t},e.setRemoteReference=function(e,t){r.expect.string(t),i._getRemoteSchemaCache[e]=t},e.prototype.validate=function(e,t,i){var n=this,r=new o;this._compileSchema(r,t).then(function(t){return r.isValid()?(n._validateSchema(r,t),r.isValid()?(n._validateObject(r,t,e),i(r.toJSON()),void 0):(i(r.toJSON()),void 0)):(i(r.toJSON()),void 0)}).fail(function(e){throw console.error(e),e}).done()},e.prototype.compileSchema=function(e,t){var i=this,n=new o;this._compileSchema(n,e).then(function(e){i._validateSchema(n,e),n.isValid()?t(void 0,e):t(n.toJSON().errors,void 0)}).done()},e.prototype.validateWithCompiled=function(e,t,i){t.__compiled!==!0&&console.warn("Schema is not compiled and might provide unexpected results.");var n=new o;this._validateObject(n,t,e);var r=n.toJSON();return i&&(n.isValid()?i(void 0,!0,r):i(r.errors,!1,r)),r},e.prototype._compileSchema=function(e,n){if(n.__compiled)return t(n);n.__compiled=!0,this._fixReferences(n);var r=i.uniq(this._collectReferences(n)),o=this,a=t();r.forEach(function(t){0===t.indexOf(n.$schema)||0!==t.indexOf("http:")&&0!==t.indexOf("https:")||(a=a.then(function(){return o._downloadRemoteReferences(e,n,t.split("#")[0])}))},this);var s=t.defer();return a.then(function(){s.resolve(n)}).done(),s.promise},e.prototype._collectReferences=function c(e){var t=[];return e.$ref&&t.push(e.$ref),i.forEach(e,function(e){(i.isObject(e)||i.isArray(e))&&(t=t.concat(c(e)))},this),t},e.prototype._fixReferences=function u(e,t){t=t||[],i.isString(e.id)&&t.push(e.id),e.$ref&&t.length>0&&(e.$ref=0===e.$ref.indexOf("#")?t.join("").split("#")[0]+e.$ref:t.join("")+e.$ref),i.forEach(e,function(e){(i.isObject(e)||i.isArray(e))&&u(e,t)},this),i.isString(e.id)&&t.pop()},e.prototype._downloadRemoteReferences=function(e,n,r){var o=this,a=t.defer();return i.getRemoteSchema(r,function(t,i){return t?(t.description="Connection failed to: "+r,e.addError(t),console.error(t.description),a.resolve()):(n.__remotes||(n.__remotes={}),o._compileSchema(e,i).then(function(e){n.__remotes[r]=e,a.resolve()}).done(),void 0)}),a.promise},e.prototype._validateSchema=function(e,t){return this.options.noTypeless===!0&&e.expect(void 0!==t.type,"EC01","type"),i.forEach(t,function(i,n){void 0!==a[n]?a[n].call(this,e,t):this.options.noExtraKeywords===!0?e.expect(!1,"EC02",n):e.addWarning('Unknown key "'+n+'" found in schema.')},this),e.isValid()},e.prototype._validateObject=function(e,t,n){r.expect.object(t);var o=!1;e.rootSchema||(e.rootSchema=t,o=!0);for(var a=99;t.$ref&&a>0;)t=i.resolveSchemaQuery(t,e.rootSchema,t.$ref),a--;return i.forEach(t,function(i,r){void 0!==s[r]&&s[r].call(this,e,t,n)},this),i.isArray(n)?this._recurseArray(e,t,n):i.isObject(n)&&this._recurseObject(e,t,n),o&&delete e.rootSchema,e.isValid()},e.prototype._recurseArray=function(e,t,n){i.isObject(t.items)&&n.forEach(function(i,n){e.goDown("["+n+"]"),this._validateObject(e,t.items,i),e.goUp()},this),i.isArray(t.items)&&n.forEach(function(n,r){r<t.items.length?(e.goDown("["+r+"]"),this._validateObject(e,t.items[r],n),e.goUp()):i.isObject(t.additionalItems)&&(e.goDown("["+r+"]"),this._validateObject(e,t.additionalItems,n),e.goUp())},this)},e.prototype._recurseObject=function(e,t,n){var r=t.additionalProperties;(r===!0||void 0===r)&&(r={});var o=i.keys(t.properties||{}),a=i.keys(t.patternProperties||{});i.forEach(n,function(n,s){var c=[];-1!==o.indexOf(s)&&c.push(t.properties[s]),a.forEach(function(e){i.getRegExp(e).test(s)===!0&&c.push(t.patternProperties[e])},this),0===c.length&&r!==!1&&c.push(r),c.forEach(function(t){e.goDown(s),this._validateObject(e,t,n),e.goUp()},this)},this)};var a={$ref:function(e,t){e.expect(i.isString(t.$ref),"KEYWORD_TYPE_EXPECTED","$ref","string")},$schema:function(e,t){e.expect(i.isString(t.$schema),"KEYWORD_TYPE_EXPECTED","$schema","string")},multipleOf:function(e,t){var n=e.expect(i.isNumber(t.multipleOf),"KEYWORD_TYPE_EXPECTED","multipleOf","number");n&&e.expect(t.multipleOf>0,"KEYWORD_MUST_BE","multipleOf","strictly greater than 0")},maximum:function(e,t){e.expect(i.isNumber(t.maximum),"KEYWORD_TYPE_EXPECTED","maximum","number")},exclusiveMaximum:function(e,t){var n=e.expect(i.isBoolean(t.exclusiveMaximum),"KEYWORD_TYPE_EXPECTED","exclusiveMaximum","boolean");n&&e.expect(void 0!==t.maximum,"IF_ONE_PRESENT_THEN_ALSO_OTHER","exclusiveMaximum","maximum")},minimum:function(e,t){e.expect(i.isNumber(t.minimum),"KEYWORD_TYPE_EXPECTED","minimum","number")},exclusiveMinimum:function(e,t){var n=e.expect(i.isBoolean(t.exclusiveMinimum),"KEYWORD_TYPE_EXPECTED","exclusiveMinimum","boolean");n&&e.expect(void 0!==t.minimum,"IF_ONE_PRESENT_THEN_ALSO_OTHER","exclusiveMinimum","minimum")},maxLength:function(e,t){var n=e.expect(i.isInteger(t.maxLength),"KEYWORD_TYPE_EXPECTED","maxLength","integer");n&&e.expect(t.maxLength>=0,"KEYWORD_MUST_BE","maxLength","greater than, or equal to 0")},minLength:function(e,t){var n=e.expect(i.isInteger(t.minLength),"KEYWORD_TYPE_EXPECTED","minLength","integer");n&&e.expect(t.minLength>=0,"KEYWORD_MUST_BE","minLength","greater than, or equal to 0")},pattern:function(e,t){var n=e.expect(i.isString(t.pattern),"KEYWORD_TYPE_EXPECTED","pattern","string");if(n)try{i.getRegExp(t.pattern)}catch(r){e.addError("IS_NOT_REGEXP",t.pattern)}},additionalItems:function(e,t){var n=i.isBoolean(t.additionalItems),r=i.isObject(t.additionalItems),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","additionalItems",["boolean","object"]);o&&r&&(e.goDown("additionalItems"),this._validateSchema(e,t.additionalItems),e.goUp())},items:function(e,t){var n=i.isArray(t.items),r=i.isObject(t.items),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","items",["array","object"]);o&&(r?(e.goDown("items"),this._validateSchema(e,t.items),e.goUp()):n&&t.items.forEach(function(t,i){e.goDown("items["+i+"]"),this._validateSchema(e,t),e.goUp()},this),this.options.forceAdditional===!0&&e.expect(void 0!==t.additionalItems,"EC01","additionalItems"))},maxItems:function(e,t){var n=e.expect(i.isInteger(t.maxItems),"KEYWORD_TYPE_EXPECTED","maxItems","integer");n&&e.expect(t.maxItems>=0,"KEYWORD_MUST_BE","maxItems","greater than, or equal to 0")},minItems:function(e,t){var n=e.expect(i.isInteger(t.minItems),"KEYWORD_TYPE_EXPECTED","minItems","integer");n&&e.expect(t.minItems>=0,"KEYWORD_MUST_BE","minItems","greater than, or equal to 0")},uniqueItems:function(e,t){e.expect(i.isBoolean(t.uniqueItems),"KEYWORD_TYPE_EXPECTED","uniqueItems","boolean")},maxProperties:function(e,t){var n=e.expect(i.isInteger(t.maxProperties),"KEYWORD_TYPE_EXPECTED","maxProperties","integer");n&&e.expect(t.maxProperties>=0,"KEYWORD_MUST_BE","maxProperties","greater than, or equal to 0")},minProperties:function(e,t){var n=e.expect(i.isInteger(t.minProperties),"KEYWORD_TYPE_EXPECTED","minProperties","integer");n&&e.expect(t.minProperties>=0,"KEYWORD_MUST_BE","minProperties","greater than, or equal to 0")},required:function(e,t){var n;n=e.expect(i.isArray(t.required),"KEYWORD_TYPE_EXPECTED","required","array"),n&&(n=e.expect(t.required.length>0,"KEYWORD_MUST_BE","required","an array with at least one element."),n&&(t.required.forEach(function(t){e.expect(i.isString(t),'Each element of "required" array must be a string.')},this),e.expect(i.isUniqueArray(t.required),'Elements in "required" array must be unique.')))},additionalProperties:function(e,t){var n=i.isBoolean(t.additionalProperties),r=i.isObject(t.additionalProperties),o=e.expect(n||r,"KEYWORD_TYPE_EXPECTED","additionalProperties",["boolean","object"]);o&&r&&(e.goDown("additionalProperties"),this._validateSchema(e,t.additionalProperties),e.goUp())},properties:function(e,t){var n=e.expect(i.isObject(t.properties),"KEYWORD_TYPE_EXPECTED","properties","object");n&&(i.forEach(t.properties,function(t,i){e.goDown("properties["+i+"]"),this._validateSchema(e,t),e.goUp()},this),this.options.forceAdditional===!0&&e.expect(void 0!==t.additionalProperties,"EC01","additionalProperties"))},patternProperties:function(e,t){var n=e.expect(i.isObject(t.patternProperties),"KEYWORD_TYPE_EXPECTED","patternProperties","object");n&&i.forEach(t.patternProperties,function(t,n){try{i.getRegExp(n)}catch(r){e.addError("IS_NOT_REGEXP",n)}e.goDown("patternProperties["+n+"]"),this._validateSchema(e,t),e.goUp()},this)},dependencies:function(e,t){var n=e.expect(i.isObject(t.dependencies),"KEYWORD_TYPE_EXPECTED","dependencies","object");n&&i.forEach(t.dependencies,function(t,n){var r=i.isObject(t),o=i.isArray(t);e.expect(r||o,'Each value of "dependencies" must be either an object or an array.'),r?(e.goDown("dependencies["+n+"]"),this._validateSchema(e,t),e.goUp()):o&&(e.expect(t.length>0,'"dependencies" array must have at least one element.'),t.forEach(function(t){e.expect(i.isString(t),'Each element of "dependencies" array must be a string.')},this),e.expect(i.isUniqueArray(t),'Elements in "dependencies" array must be unique.'))},this)},"enum":function(e,t){var n;n=e.expect(i.isArray(t.enum),"KEYWORD_TYPE_EXPECTED","enum","array"),n&&(n=e.expect(t.enum.length>0,"KEYWORD_MUST_BE","enum","an array with at least one element."),n&&(n=e.expect(i.isUniqueArray(t.enum),'Elements in "enum" array must be unique.')))},type:function(e,t){var n,r=["array","boolean","integer","number","null","object","string"],o=r.join(","),a=i.isString(t.type),s=i.isArray(t.type);n=e.expect(a||s,"KEYWORD_TYPE_EXPECTED","type",["string","array"]),n&&(s?(t.type.forEach(function(t){e.expect(-1!==r.indexOf(t),'"type" array must consist of strings: '+o+".")},this),e.expect(i.isUniqueArray(t.type),'Elements in "type" array must be unique.')):e.expect(-1!==r.indexOf(t.type),'"type" string must be one of '+o+"."),this.options.noZeroLengthStrings===!0&&("string"===t.type||s&&-1!==t.type.indexOf("string"))&&void 0===t.minLength&&(t.minLength=1),this.options.forceProperties===!0&&("object"===t.type||s&&-1!==t.type.indexOf("object"))&&e.expect(void 0!==t.properties||void 0!==t.patternProperties,"EC01","properties"),this.options.forceItems===!0&&("array"===t.type||s&&-1!==t.type.indexOf("array"))&&e.expect(void 0!==t.items,"EC01","items"),this.options.forceMaxLength===!0&&("string"===t.type||s&&-1!==t.type.indexOf("string"))&&e.expect(void 0!==t.maxLength||void 0!==t.format||void 0!==t.enum,"EC01","maxLength"))},allOf:function(e,t){var n;n=e.expect(i.isArray(t.allOf),"KEYWORD_TYPE_EXPECTED","allOf","array"),n&&(n=e.expect(t.allOf.length>0,"KEYWORD_MUST_BE","allOf","an array with at least one element."),n&&t.allOf.forEach(function(t,i){e.goDown("allOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},anyOf:function(e,t){var n;n=e.expect(i.isArray(t.anyOf),"KEYWORD_TYPE_EXPECTED","anyOf","array"),n&&(n=e.expect(t.anyOf.length>0,"KEYWORD_MUST_BE","anyOf","an array with at least one element."),n&&t.anyOf.forEach(function(t,i){e.goDown("anyOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},oneOf:function(e,t){var n;n=e.expect(i.isArray(t.oneOf),"KEYWORD_TYPE_EXPECTED","oneOf","array"),n&&(n=e.expect(t.oneOf.length>0,"KEYWORD_MUST_BE","oneOf","an array with at least one element."),n&&t.oneOf.forEach(function(t,i){e.goDown("oneOf["+i+"]"),this._validateSchema(e,t),e.goUp()},this))},not:function(e,t){var n;n=e.expect(i.isObject(t.not),"KEYWORD_TYPE_EXPECTED","not","object"),n&&(e.goDown("not"),this._validateSchema(e,t.not),e.goUp())},definitions:function(e,t){var n;n=e.expect(i.isObject(t.definitions),"KEYWORD_TYPE_EXPECTED","definitions","object"),n&&i.forEach(t.definitions,function(t,i){e.goDown("definitions["+i+"]"),this._validateSchema(e,t),e.goUp()},this)},format:function(e,t){var r;r=e.expect(i.isString(t.format),"KEYWORD_TYPE_EXPECTED","format","string"),r&&(r=e.expect(i.isFunction(n[t.format]),"There is no validator function defined for format. ("+t.format+")"))},id:function(e,t){e.expect(i.isString(t.id),"KEYWORD_TYPE_EXPECTED","id","string")},description:function(e,t){e.expect(i.isString(t.description),"KEYWORD_TYPE_EXPECTED","description","string")},"default":function(){},__compiled:function(e,t){r.expect.boolean(t.__compiled)}},s={multipleOf:function(e,t,n){if(i.isNumber(n)){var r="integer"===i.whatIs(n/t.multipleOf);e.expect(r,n+" is not a multiple of "+t.multipleOf)}},maximum:function(e,t,n){i.isNumber(n)&&(t.exclusiveMaximum!==!0?e.expect(n<=t.maximum,n+" is bigger than maximum of "+t.maximum):e.expect(n<t.maximum,n+" is bigger or equal to the exclusiveMaximum of "+t.maximum))},exclusiveMaximum:function(){},minimum:function(e,t,n){i.isNumber(n)&&(t.exclusiveMinimum!==!0?e.expect(n>=t.minimum,n+" is less than minimum of "+t.minimum):e.expect(n>t.minimum,n+" is less or equal to the exclusiveMinimum of "+t.minimum))},exclusiveMinimum:function(){},maxLength:function(e,t,n){i.isString(n)&&e.expect(n.length<=t.maxLength,n+" is longer than maxLength of "+t.maxLength)},minLength:function(e,t,n){i.isString(n)&&e.expect(n.length>=t.minLength,n+" is shorter than minLength of "+t.minLength)},pattern:function(e,t,n){i.isString(n)&&e.expect(i.getRegExp(t.pattern).test(n),n+" did not pass pattern validation to "+t.pattern)},additionalItems:function(e,t,n){i.isArray(n)&&t.additionalItems===!1&&i.isArray(t.items)&&e.expect(n.length<=t.items.length,"")},items:function(){},maxItems:function(e,t,n){i.isArray(n)&&e.expect(n.length<=t.maxItems,"Array has more items than maxItems of "+t.maxItems)},minItems:function(e,t,n){i.isArray(n)&&e.expect(n.length>=t.minItems,"Array has less items than minItems of "+t.minItems)},uniqueItems:function(e,t,n){i.isArray(n)&&t.uniqueItems===!0&&e.expect(i.isUniqueArray(n),"Items in this array are not unique as they should be.")},maxProperties:function(e,t,n){i.isObject(n)&&e.expect(i.keys(n).length<=t.maxProperties,"Object has more properties than maxProperties of "+t.maxProperties)},minProperties:function(e,t,n){i.isObject(n)&&e.expect(i.keys(n).length>=t.minProperties,"Object has less properties than minProperties of "+t.minProperties)},required:function(e,t,n){i.isObject(n)&&t.required.forEach(function(t){e.expect(void 0!==n[t],'Object is required to have a property "'+t+'"')})},additionalProperties:function(e,t){return void 0===t.properties&&void 0===t.patternProperties?s.properties.apply(this,arguments):void 0},properties:function(e,t,n){if(i.isObject(n)){var r=void 0!==t.properties?t.properties:{},o=void 0!==t.patternProperties?t.patternProperties:{};if(t.additionalProperties===!1){var a=i.keys(n),s=i.keys(r),c=i.keys(o);a=i.difference(a,s),c.forEach(function(e){for(var t=i.getRegExp(e),n=a.length-1;n>=0;n--)t.test(a[n])===!0&&a.splice(n,1)},this),e.expect(0===a.length,"E001",a.join(","))}}},patternProperties:function(e,t){return void 0===t.properties?s.properties.apply(this,arguments):void 0},dependencies:function(e,t,n){i.isObject(n)&&i.forEach(t.dependencies,function(t,r){void 0!==n[r]&&(i.isObject(t)?this._validateObject(e,t,n):i.forEach(t,function(t){e.expect(void 0!==n[t],"Object MUST include property from dependencies ("+t+").")},this))},this)},"enum":function(e,t,n){for(var r=!1,o=0,a=t.enum.length;a>o;o++)if(i.areEqual(n,t.enum[o])){r=!0;break}e.expect(r,"E003",n)},type:function(e,t,n){var r=i.whatIs(n);if(i.isString(t.type))e.expect(r===t.type||"integer"===r&&"number"===t.type,"E004",n,t.type,r);else{var o=-1!==t.type.indexOf(r),a="integer"===r&&-1!==t.type.indexOf("number");e.expect(o||a,n+" is expected to be one of "+t.type)}},allOf:function(e,t,i){t.allOf.forEach(function(t){this._validateObject(e,t,i)},this)},anyOf:function(e,t,i){for(var n=0,r=[],a=0,s=t.anyOf.length;s>a;a++){var c=new o(e);if(this._validateObject(c,t.anyOf[a],i),c.isValid()){n++;break}r.push(c)}e.expect(n>=1,"E002","anyOf"),0===n&&e.addSubReports("[anyOf]",r)},oneOf:function(e,t,i){for(var n=0,r=[],a=0,s=t.oneOf.length;s>a;a++){var c=new o(e);this._validateObject(c,t.oneOf[a],i),c.isValid()?n++:r.push(c)}e.expect(n>0,"E002","oneOf"),e.expect(2>n,"E006","oneOf"),0===n&&e.addSubReports("[oneOf]",r)},not:function(e,t,i){var n=new o(e);this._validateObject(n,t.not,i),e.expect(!n.isValid(),'Instance validated against a schema in "not"')},definitions:function(){},format:function(e,t,i){e.expect(n[t.format](i),"E005",t.format,i)}};module.exports=e}();

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc