Add check of special type

This commit is contained in:
jim1_lin
2016-02-26 17:23:40 +08:00
committed by Jim Lin
parent d067c0ba61
commit dec95ca4fa

View File

@@ -736,21 +736,30 @@ function getObjectType(obj) {
case 'Pointer' : case 'Pointer' :
if(obj.className) { if(obj.className) {
return '*' + obj.className; return '*' + obj.className;
} else {
throw new Parse.Error(Parse.Error.INVALID_POINTER, JSON.stringify(obj) + " is not a valid Pointer");
} }
break; break;
case 'File' : case 'File' :
if(obj.url && obj.name) { if(obj.url && obj.name) {
return 'file'; return 'file';
} else {
let msg = obj.name? JSON.stringify(obj) + " is not a valid File" : "File has no name";
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, msg);
} }
break; break;
case 'Date' : case 'Date' :
if(obj.iso) { if(obj.iso) {
return 'date'; return 'date';
} else {
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid Date");
} }
break; break;
case 'GeoPoint' : case 'GeoPoint' :
if(obj.latitude != null && obj.longitude != null) { if(obj.latitude != null && obj.longitude != null) {
return 'geopoint'; return 'geopoint';
} else {
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, JSON.stringify(obj) + " is not a valid GeoPoint");
} }
break; break;
default : default :