/*
	Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

/*
	This is a compiled version of Dojo, built for deployment and not for
	development. To get an editable version, please visit:

		http://dojotoolkit.org

	for documentation and information on getting the source.
*/

if(!dojo._hasResource["dojox.json.schema"]){dojo._hasResource["dojox.json.schema"]=true;dojo.provide("dojox.json.schema");dojox.json.schema.validate=function(_1,_2){return this._validate(_1,_2,false);};dojox.json.schema.checkPropertyChange=function(_3,_4){return this._validate(_3,_4,true);};dojox.json.schema.mustBeValid=function(_5){if(!_5.valid){throw new Error(dojo.map(_5.errors,function(_6){return _6.property+" "+_6.message;}).join(","));}};dojox.json.schema._validate=function(_7,_8,_9){var _a=[];function _b(_c,_d,_e,i){_e+=_e?typeof i=="number"?"["+i+"]":typeof i=="undefined"?"":"."+i:i;function _f(_10){_a.push({property:_e,message:_10});};if(typeof _d!="object"||_d instanceof Array){if(_d){_f("Invalid schema/property definition "+_d);}return null;}if(_9&&_d.readonly){_f("is a readonly field, it can not be changed");}if(_d["extends"]){_b(_c,_d["extends"],_e,i);}function _11(_12,_13){if(_12){if(typeof _12=="string"&&_12!="any"&&(_12=="null"?_13!==null:typeof _13!=_12)&&!(_13 instanceof Array&&_12=="array")&&!(_12=="integer"&&_13%1===0)){return [{property:_e,message:(typeof _13)+" value found, but a "+_12+" is required"}];}if(_12 instanceof Array){var _14=[];for(var j=0;j<_12.length;j++){if(!(_14=_11(_12[j],_13)).length){break;}}if(_14.length){return _14;}}else{if(typeof _12=="object"){var _15=_a;_a=[];_b(_13,_12,_e);var _16=_a;_a=_15;return _16;}}}return [];};if(_c===undefined){if(!_d.optional){_f("is missing and it is not optional");}}else{_a=_a.concat(_11(_d.type,_c));if(_d.disallow&&!_11(_d.disallow,_c).length){_f(" disallowed value was matched");}if(_c!==null){if(_c instanceof Array){if(_d.items){if(_d.items instanceof Array){for(i=0,l=_c.length;i<l;i++){_a.concat(_b(_c[i],_d.items[i],_e,i));}}else{for(i=0,l=_c.length;i<l;i++){_a.concat(_b(_c[i],_d.items,_e,i));}}}if(_d.minItems&&_c.length<_d.minItems){_f("There must be a minimum of "+_d.minItems+" in the array");}if(_d.maxItems&&_c.length>_d.maxItems){_f("There must be a maximum of "+_d.maxItems+" in the array");}}else{if(_d.properties&&typeof _c=="object"){_a.concat(_17(_c,_d.properties,_e,_d.additionalProperties));}}if(_d.pattern&&typeof _c=="string"&&!_c.match(_d.pattern)){_f("does not match the regex pattern "+_d.pattern);}if(_d.maxLength&&typeof _c=="string"&&_c.length>_d.maxLength){_f("may only be "+_d.maxLength+" characters long");}if(_d.minLength&&typeof _c=="string"&&_c.length<_d.minLength){_f("must be at least "+_d.minLength+" characters long");}if(typeof _d.minimum!==undefined&&typeof _c==typeof _d.minimum&&_d.minimum>_c){_f("must have a minimum value of "+_d.minimum);}if(typeof _d.maximum!==undefined&&typeof _c==typeof _d.maximum&&_d.maximum<_c){_f("must have a maximum value of "+_d.maximum);}if(_d["enum"]){var _18=_d["enum"];l=_18.length;var _19;for(var j=0;j<l;j++){if(_18[j]===_c){_19=1;break;}}if(!_19){_f("does not have a value in the enumeration "+_18.join(", "));}}if(typeof _d.maxDecimal=="number"&&(_c.toString().match(new RegExp("\\.[0-9]{"+(_d.maxDecimal+1)+",}")))){_f("may only have "+_d.maxDecimal+" digits of decimal places");}}}return null;};function _17(_1a,_1b,_1c,_1d){if(typeof _1b=="object"){if(typeof _1a!="object"||_1a instanceof Array){_a.push({property:_1c,message:"an object is required"});}for(var i in _1b){if(_1b.hasOwnProperty(i)){var _1e=_1a[i];var _1f=_1b[i];_b(_1e,_1f,_1c,i);}}}for(i in _1a){if(_1a.hasOwnProperty(i)&&(i.charAt(0)!="_"||i.charAt(0)!="_")&&_1b&&!_1b[i]&&_1d===false){_a.push({property:_1c,message:(typeof _1e)+"The property "+i+" is not defined in the schema and the schema does not allow additional properties"});}var _20=_1b&&_1b[i]&&_1b[i].requires;if(_20&&!(_20 in _1a)){_a.push({property:_1c,message:"the presence of the property "+i+" requires that "+_20+" also be present"});}_1e=_1a[i];if(_1b&&typeof _1b=="object"&&!(i in _1b)){_b(_1e,_1d,_1c,i);}if(!_9&&_1e&&_1e.$schema){_a=_a.concat(_b(_1e,_1e.$schema,_1c,i));}}return _a;};if(_8){_b(_7,_8,"","");}if(!_9&&_7&&_7.$schema){_b(_7,_7.$schema,"","");}return {valid:!_a.length,errors:_a};};}
