Added ability to add a validation function to a Cloud Code function
This commit is contained in:
@@ -10,6 +10,14 @@ var router = new PromiseRouter();
|
||||
function handleCloudFunction(req) {
|
||||
// TODO: set user from req.auth
|
||||
if (Parse.Cloud.Functions[req.params.functionName]) {
|
||||
// Run the validator for this function first
|
||||
if (Parse.Cloud.Validators[req.params.functionName]) {
|
||||
var result = Parse.Cloud.Validators[req.params.functionName](req.body);
|
||||
if (!result) {
|
||||
throw new Parse.Error(Parse.Error.SCRIPT_FAILED, 'Validation failed.');
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var response = createResponseObject(resolve, reject);
|
||||
var request = {
|
||||
|
||||
Reference in New Issue
Block a user