add invalid __type check
This commit is contained in:
@@ -336,6 +336,11 @@ describe('Parse.Object testing', () => {
|
||||
item.save({ "foo^bar": "baz" }).then(fail, done);
|
||||
});
|
||||
|
||||
it("invalid __type", function(done) {
|
||||
var item = new Parse.Object("Item");
|
||||
item.save({ "foo": {__type: "IvalidName"} }).then(fail, done);
|
||||
});
|
||||
|
||||
it("simple field deletion", function(done) {
|
||||
var simple = new Parse.Object("SimpleObject");
|
||||
simple.save({
|
||||
|
||||
@@ -731,19 +731,31 @@ function getObjectType(obj) {
|
||||
if (obj instanceof Array) {
|
||||
return 'array';
|
||||
}
|
||||
if (obj.__type === 'Pointer' && obj.className) {
|
||||
return '*' + obj.className;
|
||||
}
|
||||
if (obj.__type === 'File' && obj.name) {
|
||||
return 'file';
|
||||
}
|
||||
if (obj.__type === 'Date' && obj.iso) {
|
||||
return 'date';
|
||||
}
|
||||
if (obj.__type == 'GeoPoint' &&
|
||||
obj.latitude != null &&
|
||||
obj.longitude != null) {
|
||||
return 'geopoint';
|
||||
if (obj.__type){
|
||||
switch(obj.__type) {
|
||||
case 'Pointer' :
|
||||
if(obj.className) {
|
||||
return '*' + obj.className;
|
||||
}
|
||||
break;
|
||||
case 'File' :
|
||||
if(obj.url && obj.name) {
|
||||
return 'file';
|
||||
}
|
||||
break;
|
||||
case 'Date' :
|
||||
if(obj.iso) {
|
||||
return 'date';
|
||||
}
|
||||
break;
|
||||
case 'GeoPoint' :
|
||||
if(obj.latitude != null && obj.longitude != null) {
|
||||
return 'geopoint';
|
||||
}
|
||||
break;
|
||||
default :
|
||||
throw new Parse.Error(Parse.Error.INCORRECT_TYPE, 'invalid type: ' + obj.__type);
|
||||
}
|
||||
}
|
||||
if (obj['$ne']) {
|
||||
return getObjectType(obj['$ne']);
|
||||
|
||||
Reference in New Issue
Block a user