Closed
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
As mentioned by @Cinezaster here, it is not possible to use async with a Parse.Cloud validator.
Steps to reproduce
Actual Outcome
Cloud function completes without running async validation
Expected Outcome
Validator should wait to run options function
Failing Test Case / Pull Request
- 🤩 I submitted a PR with a fix and a test case.
- 🧐 I submitted a PR with a failing test case.
Failing test:
it('set params options function async', async (done) => {
Parse.Cloud.define(
'hello',
() => {
fail('cloud function should not run.');
return 'Hello world!';
},
{
fields: {
data: {
type: Number,
required: true,
options: async val => {
await new Promise((resolve, reject) => {
setTimeout(resolve, 500);
})
return false;
},
error: 'Validation failed. Expected data to be between 1 and 5.',
},
},
}
);
try {
await Parse.Cloud.run('hello', { data: 7 })
} catch (error) {
expect(error.code).toEqual(Parse.Error.VALIDATION_ERROR);
expect(error.message).toEqual('Validation failed. Expected data to be between 1 and 5.');
}
done();
});
Environment
Server
- Parse Server version:
4.5.0
- Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc):
FILL_THIS_OUT
Database
- System (MongoDB or Postgres):
FILL_THIS_OUT
- Database version:
FILL_THIS_OUT
- Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc):
FILL_THIS_OUT