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();
});
New Issue Checklist
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
Failing test:
Environment
Server
4.5.0FILL_THIS_OUTDatabase
FILL_THIS_OUTFILL_THIS_OUTFILL_THIS_OUTLogs