text: (function(){var p={},n=function(a,g,h){var f=function(b,f,a){var c=[],j=function(b,i){var j=c.length+1;c.push(function(){return f(b,i,function(b){var f=c[j];return!b&&f?f():!b&&!f?a():a(b)})})};if(l(b)&&!o(b))for(var i=0,g=b.length;i<g;i++)j(i,b[i]);else if(k(b)&&!o(b))for(i in b)b.hasOwnProperty(i)&&j(i,b[i]);else return a();return c[0]()};return"undefined"===typeof h?function(b,f){if(l(b)&&!o(b))for(var a=0,c=b.length;a<c;a++)f.apply(b,[a,b[a]]);if(k(b)&&!o(b))for(var j in b)b.hasOwnProperty(j)&&
  f.apply(b,[j,b[j]])}.apply(this,arguments):f.apply(this,arguments)},A=function(a,g,h){return Array.prototype.filter.apply(a,[g,h||this])},l=function(a){return"[object Array]"===Object.prototype.toString.call(a)},B=function(a){return"boolean"===typeof a},s=function(a){return"undefined"!==typeof a},o=function(a){if(q(a))return!1;if(null===a)return!0;if(l(a)||"string"===typeof a)return 0===a.length;if(k(a))for(var g in a)if(hasOwnProperty.call(a,g))return!1;return!0},w=function(a,g){if(l(a,g))return a.length!==
  g.length?!1:Array.prototype.every.apply(a,[function(b,f){return g[f]===b}]);if(k(a,g)){var h=Object.keys(a),f=Object.keys(g);if(!w(h,f))return!1;for(key in a)if(!g[key]||a[key]!==g[key])return!1;return!0}return!1},t=function(a){return"function"===typeof a},x=function(a){return q(a)&&0===a%1},C=function(a){return null===a},q=function(a){return"number"===typeof a},k=function(a){return"[object Object]"===Object.prototype.toString.call(a)},m=function(a){return"string"===typeof a},u=function(a){return"undefined"===
  typeof a},y=function(a,g){for(var h in g)g.hasOwnProperty(h)&&!a.hasOwnProperty(h)&&(a[h]=g[h]);return a},z=function(a,g){for(var h=[],f=0,b=a.length;f<b;f++){var d=a[f][g];-1===h.indexOf(d)&&h.push(d)}return h},D=function(){return!0};(function(){var a=function(f){var b=this,d={singleError:!0,messages:h,cache:!1};n(d,function(a,c){b[a]=k(c)&&f[a]?y(f[a],d[a]):k(c)&&!f[a]?y({},d[a]):s(f[a])?f[a]:d[a]});this.errors=new g(this)};a.prototype.attributes={};a.prototype.addAttribute=function(f,b){return a.prototype.attributes[f]=
  b};a.prototype.addAttributeConstructor=function(f,b){return a.prototype.attributes[f]=b()};a.prototype.addAttribute("additionalProperties",function(f,b,d,a,c){var j=this;if(!0===d)return c();var i=Object.keys(b),i=A(i,function(b){return!a.properties[b]});if(o(i))return c();if(!1===d)return i.forEach(function(a){this.addError({property:this.joinPath(f,a),propertyValue:b[a]})},this),c();if(k(d))return n(i,function(a,c,e){return j.validateSchema(b[c],d,f+c,e)},c)});a.prototype.addAttribute("divisibleBy",
  function(f,b,a,e,c){if(0===a)throw Error("The value of this attribute should not be 0.");q(b)&&0!==b%a&&this.addError();return c()});a.prototype.addAttribute("enum",function(f,b,a,e,c){-1===a.indexOf(b)&&this.addError();return c()});a.prototype.addAttribute("except",function(f,b,a,e,c){-1!==a.indexOf(b)&&this.addError();return c()});a.prototype.addAttributeConstructor("format",function(){var f={"date-time":{type:"string",pattern:/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/},
  date:function(b){return m(b)?b.match(/^\d{4}-(?:0[0-9]{1}|1[0-2]{1})-[0-9]{2}$/):k(b)?"[object Date]"===Object.prototype.toString.call(b):!1},time:{type:"string",pattern:/^\d{2}:\d{2}:\d{2}$/},"utc-milisec":{type:"number"},regex:function(b){return b&&b.test&&b.exec},color:{type:"string"},style:{type:"string"},phone:{type:"number"},uri:{type:"string",pattern:/^(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?:\w+:\w+@)?((?:(?:[-\w\d{1-3}]+\.)+(?:com|org|cat|coop|int|pro|tel|xxx|net|gov|mil|biz|info|mobi|name|aero|jobs|edu|co\.uk|ac\.uk|it|fr|tv|museum|asia|local|travel|[a-z]{2})?)|((\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)(\.(\b25[0-5]\b|\b[2][0-4][0-9]\b|\b[0-1]?[0-9]?[0-9]\b)){3}))(?::[\d]{1,5})?(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?:#(?:[-\w~!$ |\/.,*:;=]|%[a-f\d]{2})*)?$/},
  email:{type:"string",pattern:/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/},"ip-address":{type:"string",pattern:/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/},ipv6:{type:"string",pattern:/(?:(?:[a-f\d]{1,4}:)*(?:[a-f\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|(?:(?:[a-f\d]{1,4}:)*[a-f\d]{1,4})?::(?:(?:[a-f\d]{1,4}:)*(?:[a-f\d]{1,4}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))?)/},
  "host-name":{type:"string"},alpha:{required:!0,type:"string",pattern:/^[a-zA-Z]+$/},alphanumeric:{required:!0,type:["string","number"],pattern:/^[a-zA-Z0-9]+$/},decimal:function(b){return!q(b)?!1:(b+"").match(/^[0-9]+(\.[0-9]{1,2})?$/)},percentage:{required:!0,type:["string","number"],pattern:/^-?[0-9]{0,2}(\.[0-9]{1,2})?$|^-?(100)(\.[0]{1,2})?$/,minimum:-100,maximum:100},port:{required:!0,type:["string","number"],pattern:/\:\d+/}};n({url:"uri",ip:"ip-address",ipv4:"ip-address",host:"host-name",hostName:"host-name"},
  function(b,a){f[b]=f[a]});return function(b,a,e,c,j){if(k(e))return this.validateProperty(b,a,e,j);if(m(e)&&!Object.prototype.hasOwnProperty.apply(f,[e]))throw Error("The format \u2018"+e+"\u2019 is not supported.");if(m(e)){e=f[e];if(t(e))return e(a)||this.addError(),j();if(k(e))return this.validateProperty(b,a,e,j)}}});a.prototype.addAttribute("length",function(f,b,a,e,c){m(b)&&b.length!==a&&this.addError();return c()});a.prototype.addAttribute("maximum",function(f,b,a,e,c){q(b)&&(e.exclusiveMaximum&&
  b>=a||b>a)&&this.addError();return c()});a.prototype.addAttribute("maxItems",function(f,b,a,e,c){l(b)&&b.length>a&&this.addError();return c()});a.prototype.addAttribute("maxLength",function(f,b,a,e,c){m(b)&&b.length>a&&this.addError();return c()});a.prototype.addAttribute("minimum",function(f,b,a,e,c){q(b)&&(e.exclusiveMinimum&&b<=a||b<a)&&this.addError();return c()});a.prototype.addAttribute("minItems",function(f,b,a,e,c){l(b)&&b.length<a&&this.addError();return c()});a.prototype.addAttribute("minLength",
  function(f,b,a,e,c){m(b)&&b.length<a&&this.addError();return c()});a.prototype.addAttribute("pattern",function(f,b,a,e,c){m(b)&&!b.match(a)&&this.addError();return c()});(function(){a.prototype.addAttribute("patternProperties",function(f,b,a,e,c){var j=this;if(o(a))return c();var i={},g=Object.keys(a);n(b,function(b){n(g,function(f,c){b.match(RegExp(c))&&(i[b]=a[c])})});if(o(i))return c();n(i,function(a,c,d){return j.validateSchema(b[a],c,j.joinPath(f,a),d)},c)})})();a.prototype.addAttribute("required",
  function(a,b,d,e,c){d&&(a=u(b),b=(m(b)||l(b)||k(b))&&o(b),(a||b)&&this.addError());return c()});a.prototype.addAttributeConstructor("type",function(){var a={string:m,number:q,"function":t,"boolean":B,object:k,array:l,integer:x,"int":x,"null":C,any:D};return function(b,d,e,c,j){if(l(e))e.some(function(b){if(!Object.prototype.hasOwnProperty.apply(a,[b]))throw Error("Type \u2018"+e+"\u2019 is not supported.");return a[b](d)})||this.errors.addError();else{if(!Object.prototype.hasOwnProperty.apply(a,[e]))throw Error("Type \u2018"+
  e+"\u2019 is not supported.");a[e](d)||this.addError()}return j()}});(function(){a.prototype.addAttribute("uniqueItems",function(a,b,d,e,c){var j=this;n(b,function(c,d){m(d)&&b.indexOf(d)<c&&j.addError();(k(d)||l(d))&&b.forEach(function(b,e){e!==c&&w(d,b)&&j.addError({property:j.joinPath(a,e)})})});return c()})})();var g=function(a){this.length=0;this.errorMessages=a.messages};g.prototype.renderErrorMessage=function(a){var b=this.errorMessages[a.attributeName];return b&&t(b)?b(a.property,a.propertyValue,
  a.attributeValue):b&&m(b)?(["property","propertyValue","attributeValue"].forEach(function(d){b=b.replace(RegExp("{{"+d+"}}","g"),a[d])}),b=b.replace(/{{validator}}/g,a.attributeValue),b.replace(/\s+/g," ")):a.message};g.prototype.push=function(a){this[this.length]={property:a.property,propertyValue:a.propertyValue,attributeName:a.attributeName,attributeValue:a.attributeValue,message:this.renderErrorMessage(a),validator:a.attributeName,validatorName:a.attributeName,validatorValue:a.attributeValue};
  this.length+=1};g.prototype.getProperties=function(){return z(this,"property")};g.prototype.getMessages=function(){return z(this,"message")};var h={required:function(a){return"The \u2018"+a+"\u2019 property is required."},minLength:function(a,b,d){return["The "+a+" property must be at least "+d+" characters.","The length of the property is "+b.length+"."].join(" ")},maxLength:function(a,b,d){return["The "+a+" property must not exceed "+d+" characters.","The length of the property is "+b.length+"."].join(" ")},
  length:function(a,b,d){return["The "+a+" property must be exactly "+d+" characters.","The length of the property is "+b.length+"."].join(" ")},format:function(a,b,d){return["The \u2018"+a+"\u2019 property must be a/an \u2018"+d+"\u2019.","The current value of the property is \u2018"+b+"\u2019"].join(" ")},type:function(a,b,d){return["The \u2018"+a+"\u2019 property must be a/an \u2018"+d+"\u2019.","The type of the property is \u2018"+typeof b+"\u2019"].join(" ")},except:function(){},minimum:function(a,
  b,d){return["The minimum value of the \u2018"+a+"\u2019 must be "+d+".","The current value of the property is \u2018"+b+"\u2019"].join(" ")},maximum:function(a,b,d){return["The maximum value of the \u2018"+a+"\u2019 must be "+d+".","The current value of the property is \u2018"+b+"\u2019."].join(" ")},pattern:function(a,b,d){return"The \u2018"+a+"\u2019 does not match the \u2018"+d+"\u2019 pattern."},maxItems:function(a,b,d){return["The \u2018"+a+"\u2019 property must not contain more than \u2018"+
  d+"\u2019 items.","Currently it contains \u2018"+b.items+"\u2019 items."].join(" ")},minItems:function(a,b,d){return["The \u2018"+a+"\u2019 property must contain at least \u2018"+d+"\u2019 items.","Currently it contains \u2018"+b.items+"\u2019 items."].join(" ")},divisibleBy:function(a,b,d){return"The \u2018"+a+"\u2019 is not divisible by \u2018"+d+"\u2019."},uniqueItems:function(a){return"All items in the \u2018"+a+"\u2019 property must be unique."},"enum":function(a,b,d){return"Value of the \u2018"+
  a+"\u2019 must be "+d.join(" or ")+"."}};a.prototype.getProperty=function(a,b){return a.match(/([a-zA-Z0-9\s]+)/g).reduce(function(a,b){return a&&s(a[b])?a[b]:void 0},b)};a.prototype.joinPath=function(a,b){a=a||"";b+="";return b.match(/^[a-zA-Z]+$/)?a?a+"."+b:b:b.match(/\d+/)?a+"["+b+"]":a+'["'+b+'"]'};a.prototype.validate=function(a,b,d){var e=this;this.instance=a;this.schema=b;var c=function(){return 0!==e.errors.length?d(e.errors):d()};if(-1!=="string,number,function,boolean,integer,int,null".split(",").indexOf(b.type))return this.validateProperty(void 0,
  a,b,c);if(-1!==["object","array"].indexOf(b.type)){if(m(a))try{a=JSON.parse(a)}catch(j){}return this.validateSchema(a,b,"",c)}if("any"===b.type||!b.type){if(m(a))try{return a=JSON.parse(a),this.validateSchema(a,b,"",c)}catch(i){}return k(a)||l(a)?this.validateSchema(a,b,"",c):this.validateProperty(void 0,a,b,c)}};a.prototype.validateItems=function(a,b,d,e){var c=this;return l(b.items)?u(b.additionalItems)||!0===b.additionalItems?n(b.items,function(b,e,g){return c.validateSchema(a[b],e,c.joinPath(d,
  b),g)},e):n(a,function(a,f,e){if(b.items[a]||k(b.additionalItems))return c.validateSchema(f,b.items[a],c.joinPath(d,a),e);if(!1===b.additionalItems)return c.errors.push({property:c.joinPath(d,a),propertyValue:f,attributeName:"additionalItems",attributeValue:!1}),e()},e):k(b.items)&&a&&!o(a)?n(a,function(e,i,g){return c.validateSchema(a[e],b.items,c.joinPath(d,e),g)},e):e()};a.prototype.validateProperties=function(a,b,d,e){var c=this;return n(b.properties,function(e,i,g){var h="object"===i.type&&i.properties,
  k="array"===i.type,m=c.getProperty(e,a),v=c.joinPath(d,e);return h||k?c.validateSchema(m,b.properties[e],v,g):c.validateProperty(v,m,i,g)},e)};a.prototype.validateProperty=function(a,b,d,e){var c=this,g={};"validateItems,validateProperties,validateSchema,validateProperty,getProperty,attributes,errors,joinPath".split(",").forEach(function(a){g[a]=this[a]},c);return!0!==d.required&&u(b)?e():n(c.attributes,function(e,h,l){var n=c.errors.length;g.addError=function(g){return k(g)?c.errors.push({property:g.property||
  a,propertyValue:g.propertyValue||b,attributeName:g.attributeName||e,attributeValue:g.attributeValue||d[e],message:g.message||void 0}):c.errors.push({property:a,propertyValue:b,attributeName:e,attributeValue:d[e],message:g})};var o=function(a){return!0===a||m(a)?(g.addError(a),l(!0)):c.errors.length>n&&c.singleError?l(!0):l()};return s(d[e])?h.apply(g,[a,b,d[e],d,o]):l()},e)};a.prototype.validateSchema=function(a,b,d,e){var c=this;return c.validateProperty(d,a,b,function(){return b.properties?c.validateProperties(a,
  b,d,e):b.items?c.validateItems(a,b,d,e):e()})};p.json=function(){return{validate:function(f,b,d,e){"function"===typeof d&&(e=d,d={});return(new a(d)).validate(f,b,e)},addAttribute:function(f,b){return a.prototype.addAttribute.apply(a,arguments)},addAttributeConstructor:function(f,b){return a.prototype.addAttributeConstructor.apply(a,arguments)}}}()})();var r=function(a){if(!Object.prototype.hasOwnProperty.apply(p,[a]))throw Error("The \u2018"+a+"\u2019 engine is not supported. Please use a different one.");
  return p[a]};r.validate=function(a,g,h,f){var b=p.json;return b.validate.apply(b,arguments)};r.addValidator=function(a,g){var h=p.json;return h.addAttribute.apply(h,arguments)};r.addAttribute=function(a,g){var h=p.json;return h.addAttribute.apply(h,arguments)};r.addAttributeConstructor=function(a,g){var h=p.json;return h.addAttributeConstructor.apply(h,arguments)};"undefined"!==typeof module&&module.exports?module.exports=r:"undefined"!==typeof define?define(function(){return r}):this.amanda=r})();