code: function checkObj(instance, objTypeDef, path, additionalProp, errors) {
  
  	if (typeof objTypeDef =='object') {
  		if (typeof instance != 'object' || Array.isArray(instance)) {
  			errors.push({
  				property: path,
  				message: "an object is required"
  			});
  		}
  
  		for(var i in objTypeDef) {
  			if (objTypeDef.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_')) {
  				var value = instance[i];
  				var propDef = objTypeDef[i];
  				checkProp(value,propDef,path,i, errors);
  			}
  		}
  	}
  
  	for(i in instance) {
  		if (instance.hasOwnProperty(i)
  				&& !(i.charAt(0) == '_'
  				&& i.charAt(1) == '_')
  				&& objTypeDef
  				&& !objTypeDef[i]
  				&& additionalProp === false)
  		{
  			errors.push({
  				property: path,
  				message: (typeof value) + "The property " + i +
  					" is not defined in the schema and the schema does not allow additional properties"
  			});
  		}
  
  		var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
  		if (requires && !(requires in instance)) {
  			errors.push({
  				property: path,
  				message: "the presence of the property " + i + " requires that "
  					+ requires + " also be present"
  			});
  		}
  
  		value = instance[i];
  		if (objTypeDef && typeof objTypeDef == 'object' && !(i in objTypeDef)) {
  			checkProp(value, additionalProp, path, i, errors);
  		}
  
  		if (!gCheckPropChange && value && value.$schema) {
  			errors = errors.concat(checkProp(value, value.$schema, path, i, errors));
  		}
  	}
  
  	return errors;
  }
docs: validate an object against a schema