mocks.js
function(obj) {
			var schema = sforce.db.schema;
			var objDesc = schema[obj.type];
			if(typeof objDesc === 'undefined')
				throw 'No type exists by the name: ' + obj.type;
			for(var key in obj) {
				if({ Id:false, type:true }[key])
					continue;
				var fieldDesc = null;
				for(var i = 0; i < objDesc.fields.length; i++) {
					var fd = objDesc.fields[i];
					if(fd.name === key) {
						fieldDesc = fd;
						break;
					}
				}
				if(fieldDesc == null)
					throw 'No field exists by the name: ' + key + 'in the type: ' + obj.type;
			}
		}
function(obj) {
			var schema = sforce.db.schema;
			var objDesc = schema[obj.type];
			if(typeof objDesc === 'undefined')
				throw 'No type exists by the name: ' + obj.type;
			for(var key in obj) {
				if({ Id:false, type:true }[key])
					continue;
				var fieldDesc = null;
				for(var i = 0; i < objDesc.fields.length; i++) {
					var fd = objDesc.fields[i];
					if(fd.name === key) {
						fieldDesc = fd;
						break;
					}
				}
				if(fieldDesc == null)
					throw 'No field exists by the name: ' + key + 'in the type: ' + obj.type;
			}
		}
Validates a given objects against the schema