/usr/share/javascript/tv4/tv4.min.js is in libjs-tv4 1.2.7+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 | (function(b,a){if(typeof define==="function"&&define.amd){define([],a)}else{if(typeof module!=="undefined"&&module.exports){module.exports=a()}else{b.tv4=a()}}}(this,function(){if(!Object.keys){Object.keys=(function(){var X=Object.prototype.hasOwnProperty,Y=!({toString:null}).propertyIsEnumerable("toString"),W=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],V=W.length;return function(ab){if(typeof ab!=="object"&&typeof ab!=="function"||ab===null){throw new TypeError("Object.keys called on non-object")}var Z=[];for(var ac in ab){if(X.call(ab,ac)){Z.push(ac)}}if(Y){for(var aa=0;aa<V;aa++){if(X.call(ab,W[aa])){Z.push(W[aa])}}}return Z}})()}if(!Object.create){Object.create=(function(){function V(){}return function(W){if(arguments.length!==1){throw new Error("Object.create implementation only accepts one parameter.")}V.prototype=W;return new V()}})()}if(!Array.isArray){Array.isArray=function(V){return Object.prototype.toString.call(V)==="[object Array]"}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(X){if(this===null){throw new TypeError()}var Y=Object(this);var V=Y.length>>>0;if(V===0){return -1}var Z=0;if(arguments.length>1){Z=Number(arguments[1]);if(Z!==Z){Z=0}else{if(Z!==0&&Z!==Infinity&&Z!==-Infinity){Z=(Z>0||-1)*Math.floor(Math.abs(Z))}}}if(Z>=V){return -1}var W=Z>=0?Z:Math.max(V-Math.abs(Z),0);for(;W<V;W++){if(W in Y&&Y[W]===X){return W}}return -1}}if(!Object.isFrozen){Object.isFrozen=function(X){var V="tv4_test_frozen_key";while(X.hasOwnProperty(V)){V+=Math.random()}try{X[V]=true;delete X[V];return false}catch(W){return true}}}var Q={"+":true,"#":true,".":true,"/":true,";":true,"?":true,"&":true};var l={"*":true};function L(V){return encodeURI(V).replace(/%25[0-9][0-9]/g,function(W){return"%"+W.substring(3)})}function U(ae){var V="";if(Q[ae.charAt(0)]){V=ae.charAt(0);ae=ae.substring(1)}var ab="";var ak="";var ag=true;var aa=false;var am=false;if(V==="+"){ag=false}else{if(V==="."){ak=".";ab="."}else{if(V==="/"){ak="/";ab="/"}else{if(V==="#"){ak="#";ag=false}else{if(V===";"){ak=";";ab=";";aa=true;am=true}else{if(V==="?"){ak="?";ab="&";aa=true}else{if(V==="&"){ak="&";ab="&";aa=true}}}}}}}var af=[];var Z=ae.split(",");var aj=[];var W={};for(var al=0;al<Z.length;al++){var ac=Z[al];var X=null;if(ac.indexOf(":")!==-1){var ai=ac.split(":");ac=ai[0];X=parseInt(ai[1],10)}var Y={};while(l[ac.charAt(ac.length-1)]){Y[ac.charAt(ac.length-1)]=true;ac=ac.substring(0,ac.length-1)}var ah={truncate:X,name:ac,suffices:Y};aj.push(ah);W[ac]=ah;af.push(ac)}var ad=function(av){var aw="";var au=0;for(var ap=0;ap<aj.length;ap++){var an=aj[ap];var ar=av(an.name);if(ar===null||ar===undefined||(Array.isArray(ar)&&ar.length===0)||(typeof ar==="object"&&Object.keys(ar).length===0)){au++;continue}if(ap===au){aw+=ak}else{aw+=(ab||",")}if(Array.isArray(ar)){if(aa){aw+=an.name+"="}for(var ao=0;ao<ar.length;ao++){if(ao>0){aw+=an.suffices["*"]?(ab||","):",";if(an.suffices["*"]&&aa){aw+=an.name+"="}}aw+=ag?encodeURIComponent(ar[ao]).replace(/!/g,"%21"):L(ar[ao])}}else{if(typeof ar==="object"){if(aa&&!an.suffices["*"]){aw+=an.name+"="}var aq=true;for(var at in ar){if(!aq){aw+=an.suffices["*"]?(ab||","):","}aq=false;aw+=ag?encodeURIComponent(at).replace(/!/g,"%21"):L(at);aw+=an.suffices["*"]?"=":",";aw+=ag?encodeURIComponent(ar[at]).replace(/!/g,"%21"):L(ar[at])}}else{if(aa){aw+=an.name;if(!am||ar!==""){aw+="="}}if(an.truncate!=null){ar=ar.substring(0,an.truncate)}aw+=ag?encodeURIComponent(ar).replace(/!/g,"%21"):L(ar)}}}return aw};ad.varNames=af;return{prefix:ak,substitution:ad}}function c(aa){if(!(this instanceof c)){return new c(aa)}var X=aa.split("{");var ad=[X.shift()];var Y=[];var Z=[];var ae=[];while(X.length>0){var W=X.shift();var ac=W.split("}")[0];var ab=W.substring(ac.length+1);var V=U(ac);Z.push(V.substitution);Y.push(V.prefix);ad.push(ab);ae=ae.concat(V.substitution.varNames)}this.fill=function(ai){var af=ad[0];for(var ah=0;ah<Z.length;ah++){var ag=Z[ah];af+=ag(ai);af+=ad[ah+1]}return af};this.varNames=ae;this.template=aa}c.prototype={toString:function(){return this.template},fillFromObject:function(V){return this.fill(function(W){return V[W]})}};var M=function M(Z,V,Y,X,aa){this.missing=[];this.missingMap={};this.formatValidators=Z?Object.create(Z.formatValidators):{};this.schemas=Z?Object.create(Z.schemas):{};this.collectMultiple=V;this.errors=[];this.handleError=V?this.collectError:this.returnError;if(X){this.checkRecursive=true;this.scanned=[];this.scannedFrozen=[];this.scannedFrozenSchemas=[];this.scannedFrozenValidationErrors=[];this.validatedSchemasKey="tv4_validation_id";this.validationErrorsKey="tv4_validation_errors_id"}if(aa){this.trackUnknownProperties=true;this.knownPropertyPaths={};this.unknownPropertyPaths={}}this.errorReporter=Y||P("en");if(typeof this.errorReporter==="string"){throw new Error("debug")}this.definedKeywords={};if(Z){for(var W in Z.definedKeywords){this.definedKeywords[W]=Z.definedKeywords[W].slice(0)}}};M.prototype.defineKeyword=function(V,W){this.definedKeywords[V]=this.definedKeywords[V]||[];this.definedKeywords[V].push(W)};M.prototype.createError=function(Z,ac,X,W,ab,aa,Y){var V=new p(Z,ac,X,W,ab);V.message=this.errorReporter(V,aa,Y);return V};M.prototype.returnError=function(V){return V};M.prototype.collectError=function(V){if(V){this.errors.push(V)}return null};M.prototype.prefixErrors=function(Y,X,W){for(var V=Y;V<this.errors.length;V++){this.errors[V]=this.errors[V].prefixWith(X,W)}return this};M.prototype.banUnknownProperties=function(Z,Y){for(var X in this.unknownPropertyPaths){var W=this.createError(n.UNKNOWN_PROPERTY,{path:X},X,"",null,Z,Y);var V=this.handleError(W);if(V){return V}}return null};M.prototype.addFormat=function(X,W){if(typeof X==="object"){for(var V in X){this.addFormat(V,X[V])}return this}this.formatValidators[X]=W};M.prototype.resolveRefs=function(W,V){if(W["$ref"]!==undefined){V=V||{};if(V[W["$ref"]]){return this.createError(n.CIRCULAR_REFERENCE,{urls:Object.keys(V).join(", ")},"","",null,undefined,W)}V[W["$ref"]]=true;W=this.getSchema(W["$ref"],V)}return W};M.prototype.getSchema=function(V,W){var X;if(this.schemas[V]!==undefined){X=this.schemas[V];return this.resolveRefs(X,W)}var ab=V;var ac="";if(V.indexOf("#")!==-1){ac=V.substring(V.indexOf("#")+1);ab=V.substring(0,V.indexOf("#"))}if(typeof this.schemas[ab]==="object"){X=this.schemas[ab];var Y=decodeURIComponent(ac);if(Y===""){return this.resolveRefs(X,W)}else{if(Y.charAt(0)!=="/"){return undefined}}var Z=Y.split("/").slice(1);for(var aa=0;aa<Z.length;aa++){var ad=Z[aa].replace(/~1/g,"/").replace(/~0/g,"~");if(X[ad]===undefined){X=undefined;break}X=X[ad]}if(X!==undefined){return this.resolveRefs(X,W)}}if(this.missing[ab]===undefined){this.missing.push(ab);this.missing[ab]=ab;this.missingMap[ab]=ab}};M.prototype.searchSchemas=function(Z,V){if(Array.isArray(Z)){for(var X=0;X<Z.length;X++){this.searchSchemas(Z[X],V)}}else{if(Z&&typeof Z==="object"){if(typeof Z.id==="string"){if(i(V,Z.id)){if(this.schemas[Z.id]===undefined){this.schemas[Z.id]=Z}}}for(var W in Z){if(W!=="enum"){if(typeof Z[W]==="object"){this.searchSchemas(Z[W],V)}else{if(W==="$ref"){var Y=d(Z[W]);if(Y&&this.schemas[Y]===undefined&&this.missingMap[Y]===undefined){this.missingMap[Y]=Y}}}}}}}};M.prototype.addSchema=function(V,W){if(typeof V!=="string"||typeof W==="undefined"){if(typeof V==="object"&&typeof V.id==="string"){W=V;V=W.id}else{return}}if(V===d(V)+"#"){V=d(V)}this.schemas[V]=W;delete this.missingMap[V];u(W,V);this.searchSchemas(W,V)};M.prototype.getSchemaMap=function(){var W={};for(var V in this.schemas){W[V]=this.schemas[V]}return W};M.prototype.getSchemaUris=function(X){var W=[];for(var V in this.schemas){if(!X||X.test(V)){W.push(V)}}return W};M.prototype.getMissingUris=function(X){var W=[];for(var V in this.missingMap){if(!X||X.test(V)){W.push(V)}}return W};M.prototype.dropSchemas=function(){this.schemas={};this.reset()};M.prototype.reset=function(){this.missing=[];this.missingMap={};this.errors=[]};M.prototype.validateAll=function(al,aa,aj,ak,af){var ae;aa=this.resolveRefs(aa);if(!aa){return null}else{if(aa instanceof p){this.errors.push(aa);return aa}}var X=this.errors.length;var ab,Y=null,ai=null;if(this.checkRecursive&&al&&typeof al==="object"){ae=!this.scanned.length;if(al[this.validatedSchemasKey]){var Z=al[this.validatedSchemasKey].indexOf(aa);if(Z!==-1){this.errors=this.errors.concat(al[this.validationErrorsKey][Z]);return null}}if(Object.isFrozen(al)){ab=this.scannedFrozen.indexOf(al);if(ab!==-1){var W=this.scannedFrozenSchemas[ab].indexOf(aa);if(W!==-1){this.errors=this.errors.concat(this.scannedFrozenValidationErrors[ab][W]);return null}}}this.scanned.push(al);if(Object.isFrozen(al)){if(ab===-1){ab=this.scannedFrozen.length;this.scannedFrozen.push(al);this.scannedFrozenSchemas.push([])}Y=this.scannedFrozenSchemas[ab].length;this.scannedFrozenSchemas[ab][Y]=aa;this.scannedFrozenValidationErrors[ab][Y]=[]}else{if(!al[this.validatedSchemasKey]){try{Object.defineProperty(al,this.validatedSchemasKey,{value:[],configurable:true});Object.defineProperty(al,this.validationErrorsKey,{value:[],configurable:true})}catch(ag){al[this.validatedSchemasKey]=[];al[this.validationErrorsKey]=[]}}ai=al[this.validatedSchemasKey].length;al[this.validatedSchemasKey][ai]=aa;al[this.validationErrorsKey][ai]=[]}}var am=this.errors.length;var ad=this.validateBasic(al,aa,af)||this.validateNumeric(al,aa,af)||this.validateString(al,aa,af)||this.validateArray(al,aa,af)||this.validateObject(al,aa,af)||this.validateCombinations(al,aa,af)||this.validateHypermedia(al,aa,af)||this.validateFormat(al,aa,af)||this.validateDefinedKeywords(al,aa,af)||null;if(ae){while(this.scanned.length){var ah=this.scanned.pop();delete ah[this.validatedSchemasKey]}this.scannedFrozen=[];this.scannedFrozenSchemas=[]}if(ad||am!==this.errors.length){while((aj&&aj.length)||(ak&&ak.length)){var V=(aj&&aj.length)?""+aj.pop():null;var ac=(ak&&ak.length)?""+ak.pop():null;if(ad){ad=ad.prefixWith(V,ac)}this.prefixErrors(am,V,ac)}}if(Y!==null){this.scannedFrozenValidationErrors[ab][Y]=this.errors.slice(X)}else{if(ai!==null){al[this.validationErrorsKey][ai]=this.errors.slice(X)}}return this.handleError(ad)};M.prototype.validateFormat=function(X,W){if(typeof W.format!=="string"||!this.formatValidators[W.format]){return null}var V=this.formatValidators[W.format].call(null,X,W);if(typeof V==="string"||typeof V==="number"){return this.createError(n.FORMAT_CUSTOM,{message:V},"","/format",null,X,W)}else{if(V&&typeof V==="object"){return this.createError(n.FORMAT_CUSTOM,{message:V.message||"?"},V.dataPath||"",V.schemaPath||"/format",null,X,W)}}return null};M.prototype.validateDefinedKeywords=function(Y,X,ac){for(var ae in this.definedKeywords){if(typeof X[ae]==="undefined"){continue}var ab=this.definedKeywords[ae];for(var Z=0;Z<ab.length;Z++){var W=ab[Z];var af=W(Y,X[ae],X,ac);if(typeof af==="string"||typeof af==="number"){return this.createError(n.KEYWORD_CUSTOM,{key:ae,message:af},"","",null,Y,X).prefixWith(null,ae)}else{if(af&&typeof af==="object"){var V=af.code;if(typeof V==="string"){if(!n[V]){throw new Error("Undefined error code (use defineError): "+V)}V=n[V]}else{if(typeof V!=="number"){V=n.KEYWORD_CUSTOM}}var ad=(typeof af.message==="object")?af.message:{key:ae,message:af.message||"?"};var aa=af.schemaPath||("/"+ae.replace(/~/g,"~0").replace(/\//g,"~1"));return this.createError(V,ad,af.dataPath||null,aa,null,Y,X)}}}}return null};function h(V,Y){if(V===Y){return true}if(V&&Y&&typeof V==="object"&&typeof Y==="object"){if(Array.isArray(V)!==Array.isArray(Y)){return false}else{if(Array.isArray(V)){if(V.length!==Y.length){return false}for(var X=0;X<V.length;X++){if(!h(V[X],Y[X])){return false}}}else{var W;for(W in V){if(Y[W]===undefined&&V[W]!==undefined){return false}}for(W in Y){if(V[W]===undefined&&Y[W]!==undefined){return false}}for(W in V){if(!h(V[W],Y[W])){return false}}}}return true}return false}M.prototype.validateBasic=function E(Y,X,V){var W;if(W=this.validateType(Y,X,V)){return W.prefixWith(null,"type")}if(W=this.validateEnum(Y,X,V)){return W.prefixWith(null,"type")}return null};M.prototype.validateType=function e(Z,Y){if(Y.type===undefined){return null}var V=typeof Z;if(Z===null){V="null"}else{if(Array.isArray(Z)){V="array"}}var aa=Y.type;if(!Array.isArray(aa)){aa=[aa]}for(var W=0;W<aa.length;W++){var X=aa[W];if(X===V||(X==="integer"&&V==="number"&&(Z%1===0))){return null}}return this.createError(n.INVALID_TYPE,{type:V,expected:aa.join("/")},"","",null,Z,Y)};M.prototype.validateEnum=function C(X,W){if(W["enum"]===undefined){return null}for(var V=0;V<W["enum"].length;V++){var Y=W["enum"][V];if(h(X,Y)){return null}}return this.createError(n.ENUM_MISMATCH,{value:(typeof JSON!=="undefined")?JSON.stringify(X):X},"","",null,X,W)};M.prototype.validateNumeric=function b(X,W,V){return this.validateMultipleOf(X,W,V)||this.validateMinMax(X,W,V)||this.validateNaN(X,W,V)||null};var G=Math.pow(2,-51);var o=1-G;M.prototype.validateMultipleOf=function z(Y,W){var V=W.multipleOf||W.divisibleBy;if(V===undefined){return null}if(typeof Y==="number"){var X=(Y/V)%1;if(X>=G&&X<o){return this.createError(n.NUMBER_MULTIPLE_OF,{value:Y,multipleOf:V},"","",null,Y,W)}}return null};M.prototype.validateMinMax=function O(W,V){if(typeof W!=="number"){return null}if(V.minimum!==undefined){if(W<V.minimum){return this.createError(n.NUMBER_MINIMUM,{value:W,minimum:V.minimum},"","/minimum",null,W,V)}if(V.exclusiveMinimum&&W===V.minimum){return this.createError(n.NUMBER_MINIMUM_EXCLUSIVE,{value:W,minimum:V.minimum},"","/exclusiveMinimum",null,W,V)}}if(V.maximum!==undefined){if(W>V.maximum){return this.createError(n.NUMBER_MAXIMUM,{value:W,maximum:V.maximum},"","/maximum",null,W,V)}if(V.exclusiveMaximum&&W===V.maximum){return this.createError(n.NUMBER_MAXIMUM_EXCLUSIVE,{value:W,maximum:V.maximum},"","/exclusiveMaximum",null,W,V)}}return null};M.prototype.validateNaN=function q(W,V){if(typeof W!=="number"){return null}if(isNaN(W)===true||W===Infinity||W===-Infinity){return this.createError(n.NUMBER_NOT_A_NUMBER,{value:W},"","/type",null,W,V)}return null};M.prototype.validateString=function g(X,W,V){return this.validateStringLength(X,W,V)||this.validateStringPattern(X,W,V)||null};M.prototype.validateStringLength=function f(W,V){if(typeof W!=="string"){return null}if(V.minLength!==undefined){if(W.length<V.minLength){return this.createError(n.STRING_LENGTH_SHORT,{length:W.length,minimum:V.minLength},"","/minLength",null,W,V)}}if(V.maxLength!==undefined){if(W.length>V.maxLength){return this.createError(n.STRING_LENGTH_LONG,{length:W.length,maximum:V.maxLength},"","/maxLength",null,W,V)}}return null};M.prototype.validateStringPattern=function m(aa,Y){if(typeof aa!=="string"||(typeof Y.pattern!=="string"&&!(Y.pattern instanceof RegExp))){return null}var Z;if(Y.pattern instanceof RegExp){Z=Y.pattern}else{var V,W="";var X=Y.pattern.match(/^\/(.+)\/([img]*)$/);if(X){V=X[1];W=X[2]}else{V=Y.pattern}Z=new RegExp(V,W)}if(!Z.test(aa)){return this.createError(n.STRING_PATTERN,{pattern:Y.pattern},"","/pattern",null,aa,Y)}return null};M.prototype.validateArray=function r(X,W,V){if(!Array.isArray(X)){return null}return this.validateArrayLength(X,W,V)||this.validateArrayUniqueItems(X,W,V)||this.validateArrayItems(X,W,V)||null};M.prototype.validateArrayLength=function B(X,W){var V;if(W.minItems!==undefined){if(X.length<W.minItems){V=this.createError(n.ARRAY_LENGTH_SHORT,{length:X.length,minimum:W.minItems},"","/minItems",null,X,W);if(this.handleError(V)){return V}}}if(W.maxItems!==undefined){if(X.length>W.maxItems){V=this.createError(n.ARRAY_LENGTH_LONG,{length:X.length,maximum:W.maxItems},"","/maxItems",null,X,W);if(this.handleError(V)){return V}}}return null};M.prototype.validateArrayUniqueItems=function S(Z,Y){if(Y.uniqueItems){for(var X=0;X<Z.length;X++){for(var W=X+1;W<Z.length;W++){if(h(Z[X],Z[W])){var V=this.createError(n.ARRAY_UNIQUE,{match1:X,match2:W},"","/uniqueItems",null,Z,Y);if(this.handleError(V)){return V}}}}}return null};M.prototype.validateArrayItems=function y(Z,Y,V){if(Y.items===undefined){return null}var W,X;if(Array.isArray(Y.items)){for(X=0;X<Z.length;X++){if(X<Y.items.length){if(W=this.validateAll(Z[X],Y.items[X],[X],["items",X],V+"/"+X)){return W}}else{if(Y.additionalItems!==undefined){if(typeof Y.additionalItems==="boolean"){if(!Y.additionalItems){W=(this.createError(n.ARRAY_ADDITIONAL_ITEMS,{},"/"+X,"/additionalItems",null,Z,Y));if(this.handleError(W)){return W}}}else{if(W=this.validateAll(Z[X],Y.additionalItems,[X],["additionalItems"],V+"/"+X)){return W}}}}}}else{for(X=0;X<Z.length;X++){if(W=this.validateAll(Z[X],Y.items,[X],["items"],V+"/"+X)){return W}}}return null};M.prototype.validateObject=function K(X,W,V){if(typeof X!=="object"||X===null||Array.isArray(X)){return null}return this.validateObjectMinMaxProperties(X,W,V)||this.validateObjectRequiredProperties(X,W,V)||this.validateObjectProperties(X,W,V)||this.validateObjectDependencies(X,W,V)||null};M.prototype.validateObjectMinMaxProperties=function J(Y,X){var W=Object.keys(Y);var V;if(X.minProperties!==undefined){if(W.length<X.minProperties){V=this.createError(n.OBJECT_PROPERTIES_MINIMUM,{propertyCount:W.length,minimum:X.minProperties},"","/minProperties",null,Y,X);if(this.handleError(V)){return V}}}if(X.maxProperties!==undefined){if(W.length>X.maxProperties){V=this.createError(n.OBJECT_PROPERTIES_MAXIMUM,{propertyCount:W.length,maximum:X.maxProperties},"","/maxProperties",null,Y,X);if(this.handleError(V)){return V}}}return null};M.prototype.validateObjectRequiredProperties=function v(Z,Y){if(Y.required!==undefined){for(var X=0;X<Y.required.length;X++){var W=Y.required[X];if(Z[W]===undefined){var V=this.createError(n.OBJECT_REQUIRED,{key:W},"","/required/"+X,null,Z,Y);if(this.handleError(V)){return V}}}}return null};M.prototype.validateObjectProperties=function A(X,V,Y){var ab;for(var ad in X){var ac=Y+"/"+ad.replace(/~/g,"~0").replace(/\//g,"~1");var aa=false;if(V.properties!==undefined&&V.properties[ad]!==undefined){aa=true;if(ab=this.validateAll(X[ad],V.properties[ad],[ad],["properties",ad],ac)){return ab}}if(V.patternProperties!==undefined){for(var W in V.patternProperties){var Z=new RegExp(W);if(Z.test(ad)){aa=true;if(ab=this.validateAll(X[ad],V.patternProperties[W],[ad],["patternProperties",W],ac)){return ab}}}}if(!aa){if(V.additionalProperties!==undefined){if(this.trackUnknownProperties){this.knownPropertyPaths[ac]=true;delete this.unknownPropertyPaths[ac]}if(typeof V.additionalProperties==="boolean"){if(!V.additionalProperties){ab=this.createError(n.OBJECT_ADDITIONAL_PROPERTIES,{key:ad},"","/additionalProperties",null,X,V).prefixWith(ad,null);if(this.handleError(ab)){return ab}}}else{if(ab=this.validateAll(X[ad],V.additionalProperties,[ad],["additionalProperties"],ac)){return ab}}}else{if(this.trackUnknownProperties&&!this.knownPropertyPaths[ac]){this.unknownPropertyPaths[ac]=true}}}else{if(this.trackUnknownProperties){this.knownPropertyPaths[ac]=true;delete this.unknownPropertyPaths[ac]}}}return null};M.prototype.validateObjectDependencies=function R(ab,Y,V){var W;if(Y.dependencies!==undefined){for(var aa in Y.dependencies){if(ab[aa]!==undefined){var ac=Y.dependencies[aa];if(typeof ac==="string"){if(ab[ac]===undefined){W=this.createError(n.OBJECT_DEPENDENCY_KEY,{key:aa,missing:ac},"","",null,ab,Y).prefixWith(null,aa).prefixWith(null,"dependencies");if(this.handleError(W)){return W}}}else{if(Array.isArray(ac)){for(var X=0;X<ac.length;X++){var Z=ac[X];if(ab[Z]===undefined){W=this.createError(n.OBJECT_DEPENDENCY_KEY,{key:aa,missing:Z},"","/"+X,null,ab,Y).prefixWith(null,aa).prefixWith(null,"dependencies");if(this.handleError(W)){return W}}}}else{if(W=this.validateAll(ab,ac,[],["dependencies",aa],V)){return W}}}}}}return null};M.prototype.validateCombinations=function D(X,W,V){return this.validateAllOf(X,W,V)||this.validateAnyOf(X,W,V)||this.validateOneOf(X,W,V)||this.validateNot(X,W,V)||null};M.prototype.validateAllOf=function I(aa,Z,V){if(Z.allOf===undefined){return null}var W;for(var Y=0;Y<Z.allOf.length;Y++){var X=Z.allOf[Y];if(W=this.validateAll(aa,X,[],["allOf",Y],V)){return W}}return null};M.prototype.validateAnyOf=function a(ab,Z,ac){if(Z.anyOf===undefined){return null}var af=[];var ag=this.errors.length;var ai,W;if(this.trackUnknownProperties){ai=this.unknownPropertyPaths;W=this.knownPropertyPaths}var ah=true;for(var aa=0;aa<Z.anyOf.length;aa++){if(this.trackUnknownProperties){this.unknownPropertyPaths={};this.knownPropertyPaths={}}var Y=Z.anyOf[aa];var ae=this.errors.length;var ad=this.validateAll(ab,Y,[],["anyOf",aa],ac);if(ad===null&&ae===this.errors.length){this.errors=this.errors.slice(0,ag);if(this.trackUnknownProperties){for(var X in this.knownPropertyPaths){W[X]=true;delete ai[X]}for(var V in this.unknownPropertyPaths){if(!W[V]){ai[V]=true}}ah=false;continue}return null}if(ad){af.push(ad.prefixWith(null,""+aa).prefixWith(null,"anyOf"))}}if(this.trackUnknownProperties){this.unknownPropertyPaths=ai;this.knownPropertyPaths=W}if(ah){af=af.concat(this.errors.slice(ag));this.errors=this.errors.slice(0,ag);return this.createError(n.ANY_OF_MISSING,{},"","/anyOf",af,ab,Z)}};M.prototype.validateOneOf=function x(ab,Z,ac){if(Z.oneOf===undefined){return null}var ag=null;var af=[];var ah=this.errors.length;var ai,W;if(this.trackUnknownProperties){ai=this.unknownPropertyPaths;W=this.knownPropertyPaths}for(var aa=0;aa<Z.oneOf.length;aa++){if(this.trackUnknownProperties){this.unknownPropertyPaths={};this.knownPropertyPaths={}}var Y=Z.oneOf[aa];var ae=this.errors.length;var ad=this.validateAll(ab,Y,[],["oneOf",aa],ac);if(ad===null&&ae===this.errors.length){if(ag===null){ag=aa}else{this.errors=this.errors.slice(0,ah);return this.createError(n.ONE_OF_MULTIPLE,{index1:ag,index2:aa},"","/oneOf",null,ab,Z)}if(this.trackUnknownProperties){for(var X in this.knownPropertyPaths){W[X]=true;delete ai[X]}for(var V in this.unknownPropertyPaths){if(!W[V]){ai[V]=true}}}}else{if(ad){af.push(ad)}}}if(this.trackUnknownProperties){this.unknownPropertyPaths=ai;this.knownPropertyPaths=W}if(ag===null){af=af.concat(this.errors.slice(ah));this.errors=this.errors.slice(0,ah);return this.createError(n.ONE_OF_MISSING,{},"","/oneOf",af,ab,Z)}else{this.errors=this.errors.slice(0,ah)}return null};M.prototype.validateNot=function s(aa,Y,V){if(Y.not===undefined){return null}var W=this.errors.length;var ab,Z;if(this.trackUnknownProperties){ab=this.unknownPropertyPaths;Z=this.knownPropertyPaths;this.unknownPropertyPaths={};this.knownPropertyPaths={}}var X=this.validateAll(aa,Y.not,null,null,V);var ac=this.errors.slice(W);this.errors=this.errors.slice(0,W);if(this.trackUnknownProperties){this.unknownPropertyPaths=ab;this.knownPropertyPaths=Z}if(X===null&&ac.length===0){return this.createError(n.NOT_PASSED,{},"","/not",null,aa,Y)}return null};M.prototype.validateHypermedia=function D(Y,W,ab){if(!W.links){return null}var ad;for(var aa=0;aa<W.links.length;aa++){var ae=W.links[aa];if(ae.rel==="describedby"){var af=new c(ae.href);var Z=true;for(var X=0;X<af.varNames.length;X++){if(!(af.varNames[X] in Y)){Z=false;break}}if(Z){var ac=af.fillFromObject(Y);var V={"$ref":ac};if(ad=this.validateAll(Y,V,[],["links",aa],ab)){return ad}}}}};function t(W){var V=String(W).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return(V?{href:V[0]||"",protocol:V[1]||"",authority:V[2]||"",host:V[3]||"",hostname:V[4]||"",port:V[5]||"",pathname:V[6]||"",search:V[7]||"",hash:V[8]||""}:null)}function F(W,V){function X(Z){var Y=[];Z.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(aa){if(aa==="/.."){Y.pop()}else{Y.push(aa)}});return Y.join("").replace(/^\//,Z.charAt(0)==="/"?"/":"")}V=t(V||"");W=t(W||"");return !V||!W?null:(V.protocol||W.protocol)+(V.protocol||V.authority?V.authority:W.authority)+X(V.protocol||V.authority||V.pathname.charAt(0)==="/"?V.pathname:(V.pathname?((W.authority&&!W.pathname?"/":"")+W.pathname.slice(0,W.pathname.lastIndexOf("/")+1)+V.pathname):W.pathname))+(V.protocol||V.authority||V.pathname?V.search:(V.search||W.search))+V.hash}function d(V){return V.split("#")[0]}function u(X,Y){if(X&&typeof X==="object"){if(Y===undefined){Y=X.id}else{if(typeof X.id==="string"){Y=F(Y,X.id);X.id=Y}}if(Array.isArray(X)){for(var W=0;W<X.length;W++){u(X[W],Y)}}else{if(typeof X["$ref"]==="string"){X["$ref"]=F(Y,X["$ref"])}for(var V in X){if(V!=="enum"){u(X[V],Y)}}}}}function P(W){W=W||"en";var V=H[W];return function(X){var Y=V[X.code]||j[X.code];if(typeof Y!=="string"){return"Unknown error code "+X.code+": "+JSON.stringify(X.messageParams)}var Z=X.params;return Y.replace(/\{([^{}]*)\}/g,function(aa,ac){var ab=Z[ac];return typeof ab==="string"||typeof ab==="number"?ab:aa})}}var n={INVALID_TYPE:0,ENUM_MISMATCH:1,ANY_OF_MISSING:10,ONE_OF_MISSING:11,ONE_OF_MULTIPLE:12,NOT_PASSED:13,NUMBER_MULTIPLE_OF:100,NUMBER_MINIMUM:101,NUMBER_MINIMUM_EXCLUSIVE:102,NUMBER_MAXIMUM:103,NUMBER_MAXIMUM_EXCLUSIVE:104,NUMBER_NOT_A_NUMBER:105,STRING_LENGTH_SHORT:200,STRING_LENGTH_LONG:201,STRING_PATTERN:202,OBJECT_PROPERTIES_MINIMUM:300,OBJECT_PROPERTIES_MAXIMUM:301,OBJECT_REQUIRED:302,OBJECT_ADDITIONAL_PROPERTIES:303,OBJECT_DEPENDENCY_KEY:304,ARRAY_LENGTH_SHORT:400,ARRAY_LENGTH_LONG:401,ARRAY_UNIQUE:402,ARRAY_ADDITIONAL_ITEMS:403,FORMAT_CUSTOM:500,KEYWORD_CUSTOM:501,CIRCULAR_REFERENCE:600,UNKNOWN_PROPERTY:1000};var N={};for(var k in n){N[n[k]]=k}var j={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": indices {index1} and {index2}',NOT_PASSED:'Data matches schema from "not"',NUMBER_MULTIPLE_OF:"Value {value} is not a multiple of {multipleOf}",NUMBER_MINIMUM:"Value {value} is less than minimum {minimum}",NUMBER_MINIMUM_EXCLUSIVE:"Value {value} is equal to exclusive minimum {minimum}",NUMBER_MAXIMUM:"Value {value} is greater than maximum {maximum}",NUMBER_MAXIMUM_EXCLUSIVE:"Value {value} is equal to exclusive maximum {maximum}",NUMBER_NOT_A_NUMBER:"Value {value} is not a valid number",STRING_LENGTH_SHORT:"String is too short ({length} chars), minimum {minimum}",STRING_LENGTH_LONG:"String is too long ({length} chars), maximum {maximum}",STRING_PATTERN:"String does not match pattern: {pattern}",OBJECT_PROPERTIES_MINIMUM:"Too few properties defined ({propertyCount}), minimum {minimum}",OBJECT_PROPERTIES_MAXIMUM:"Too many properties defined ({propertyCount}), maximum {maximum}",OBJECT_REQUIRED:"Missing required property: {key}",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 {match1} and {match2})",ARRAY_ADDITIONAL_ITEMS:"Additional items not allowed",FORMAT_CUSTOM:"Format validation failed ({message})",KEYWORD_CUSTOM:"Keyword failed: {key} ({message})",CIRCULAR_REFERENCE:"Circular $refs: {urls}",UNKNOWN_PROPERTY:"Unknown property (not in schema)"};function p(Y,aa,W,V,Z){Error.call(this);if(Y===undefined){throw new Error("No error code supplied: "+V)}this.message="";this.params=aa;this.code=Y;this.dataPath=W||"";this.schemaPath=V||"";this.subErrors=Z||null;var X=new Error(this.message);this.stack=X.stack||X.stacktrace;if(!this.stack){try{throw X}catch(X){this.stack=X.stack||X.stacktrace}}}p.prototype=Object.create(Error.prototype);p.prototype.constructor=p;p.prototype.name="ValidationError";p.prototype.prefixWith=function(X,V){if(X!==null){X=X.replace(/~/g,"~0").replace(/\//g,"~1");this.dataPath="/"+X+this.dataPath}if(V!==null){V=V.replace(/~/g,"~0").replace(/\//g,"~1");this.schemaPath="/"+V+this.schemaPath}if(this.subErrors!==null){for(var W=0;W<this.subErrors.length;W++){this.subErrors[W].prefixWith(X,V)}}return this};function i(V,X){if(X.substring(0,V.length)===V){var W=X.substring(V.length);if((X.length>0&&X.charAt(V.length-1)==="/")||W.charAt(0)==="#"||W.charAt(0)==="?"){return true}}return false}var H={};function T(Z){var Y=new M();var X;var W;var V={setErrorReporter:function(aa){if(typeof aa==="string"){return this.language(aa)}W=aa;return true},addFormat:function(){Y.addFormat.apply(Y,arguments)},language:function(aa){if(!aa){return X}if(!H[aa]){aa=aa.split("-")[0]}if(H[aa]){X=aa;return aa}return false},addLanguage:function(ac,ad){var ab;for(ab in n){if(ad[ab]&&!ad[n[ab]]){ad[n[ab]]=ad[ab]}}var aa=ac.split("-")[0];if(!H[aa]){H[ac]=ad;H[aa]=ad}else{H[ac]=Object.create(H[aa]);for(ab in ad){if(typeof H[aa][ab]==="undefined"){H[aa][ab]=ad[ab]}H[ac][ab]=ad[ab]}}return this},freshApi:function(ab){var aa=T();if(ab){aa.language(ab)}return aa},validate:function(ah,af,ac,ae){var ag=P(X);var ad=W?function(ai,ak,aj){return W(ai,ak,aj)||ag(ai,ak,aj)}:ag;var ab=new M(Y,false,ad,ac,ae);if(typeof af==="string"){af={"$ref":af}}ab.addSchema("",af);var aa=ab.validateAll(ah,af,null,null,"");if(!aa&&ae){aa=ab.banUnknownProperties(ah,af)}this.error=aa;this.missing=ab.missing;this.valid=(aa===null);return this.valid},validateResult:function(){var aa={};this.validate.apply(aa,arguments);return aa},validateMultiple:function(ah,af,ac,ae){var ag=P(X);var ad=W?function(ai,ak,aj){return W(ai,ak,aj)||ag(ai,ak,aj)}:ag;var ab=new M(Y,true,ad,ac,ae);if(typeof af==="string"){af={"$ref":af}}ab.addSchema("",af);ab.validateAll(ah,af,null,null,"");if(ae){ab.banUnknownProperties(ah,af)}var aa={};aa.errors=ab.errors;aa.missing=ab.missing;aa.valid=(aa.errors.length===0);return aa},addSchema:function(){return Y.addSchema.apply(Y,arguments)},getSchema:function(){return Y.getSchema.apply(Y,arguments)},getSchemaMap:function(){return Y.getSchemaMap.apply(Y,arguments)},getSchemaUris:function(){return Y.getSchemaUris.apply(Y,arguments)},getMissingUris:function(){return Y.getMissingUris.apply(Y,arguments)},dropSchemas:function(){Y.dropSchemas.apply(Y,arguments)},defineKeyword:function(){Y.defineKeyword.apply(Y,arguments)},defineError:function(aa,ac,ab){if(typeof aa!=="string"||!/^[A-Z]+(_[A-Z]+)*$/.test(aa)){throw new Error("Code name must be a string in UPPER_CASE_WITH_UNDERSCORES")}if(typeof ac!=="number"||ac%1!==0||ac<10000){throw new Error("Code number must be an integer > 10000")}if(typeof n[aa]!=="undefined"){throw new Error("Error already defined: "+aa+" as "+n[aa])}if(typeof N[ac]!=="undefined"){throw new Error("Error code already used: "+N[ac]+" as "+ac)}n[aa]=ac;N[ac]=aa;j[aa]=j[ac]=ab;for(var ae in H){var ad=H[ae];if(ad[aa]){ad[ac]=ad[ac]||ad[aa]}}},reset:function(){Y.reset();this.error=null;this.missing=[];this.valid=true},missing:[],error:null,valid:true,normSchema:u,resolveUrl:F,getDocumentUri:d,errorCodes:n};V.language(Z||"en");return V}var w=T();w.addLanguage("en-gb",j);w.tv4=w;return w}));
|