add invalid __type check
This commit is contained in:
@@ -335,6 +335,11 @@ describe('Parse.Object testing', () => {
|
|||||||
'Item should not be updated with invalid key.');
|
'Item should not be updated with invalid key.');
|
||||||
item.save({ "foo^bar": "baz" }).then(fail, done);
|
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) {
|
it("simple field deletion", function(done) {
|
||||||
var simple = new Parse.Object("SimpleObject");
|
var simple = new Parse.Object("SimpleObject");
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ Schema.prototype.validateRequiredColumns = function(className, object, query) {
|
|||||||
if (!columns || columns.length == 0) {
|
if (!columns || columns.length == 0) {
|
||||||
return Promise.resolve(this);
|
return Promise.resolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
var missingColumns = columns.filter(function(column){
|
var missingColumns = columns.filter(function(column){
|
||||||
if (query && query.objectId) {
|
if (query && query.objectId) {
|
||||||
if (object[column] && typeof object[column] === "object") {
|
if (object[column] && typeof object[column] === "object") {
|
||||||
@@ -636,15 +636,15 @@ Schema.prototype.validateRequiredColumns = function(className, object, query) {
|
|||||||
// Not trying to do anything there
|
// Not trying to do anything there
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !object[column]
|
return !object[column]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (missingColumns.length > 0) {
|
if (missingColumns.length > 0) {
|
||||||
throw new Parse.Error(
|
throw new Parse.Error(
|
||||||
Parse.Error.INCORRECT_TYPE,
|
Parse.Error.INCORRECT_TYPE,
|
||||||
missingColumns[0]+' is required.');
|
missingColumns[0]+' is required.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(this);
|
return Promise.resolve(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,19 +731,31 @@ function getObjectType(obj) {
|
|||||||
if (obj instanceof Array) {
|
if (obj instanceof Array) {
|
||||||
return 'array';
|
return 'array';
|
||||||
}
|
}
|
||||||
if (obj.__type === 'Pointer' && obj.className) {
|
if (obj.__type){
|
||||||
return '*' + obj.className;
|
switch(obj.__type) {
|
||||||
}
|
case 'Pointer' :
|
||||||
if (obj.__type === 'File' && obj.name) {
|
if(obj.className) {
|
||||||
return 'file';
|
return '*' + obj.className;
|
||||||
}
|
}
|
||||||
if (obj.__type === 'Date' && obj.iso) {
|
break;
|
||||||
return 'date';
|
case 'File' :
|
||||||
}
|
if(obj.url && obj.name) {
|
||||||
if (obj.__type == 'GeoPoint' &&
|
return 'file';
|
||||||
obj.latitude != null &&
|
}
|
||||||
obj.longitude != null) {
|
break;
|
||||||
return 'geopoint';
|
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']) {
|
if (obj['$ne']) {
|
||||||
return getObjectType(obj['$ne']);
|
return getObjectType(obj['$ne']);
|
||||||
|
|||||||
Reference in New Issue
Block a user