I’ve created Multiple beforeSave validation using cloud function.
However I kept getting errors on the Moralis Logs:
If I only set beforeSave one class, it works just fine.
2022-06-08T08:29:17.182Z - Error: Before save opts already set for _User
at Object.Moralis.Cloud.beforeSave (/moralis-server/lib/cloud-code/plugins/index.js:92:33)
at eval (eval at customUserPlugin (/moralis-server/cloud/main.js:157:21), <anonymous>:1:605)
at customUserPlugin (/moralis-server/cloud/main.js:157:21)
at /moralis-server/lib/cloud-code/plugins/index.js:144:15
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.initialize (/moralis-server/lib/cloud-code/plugins/index.js:133:3)
My code:
Moralis.Cloud.beforeSave(Moralis.User, async (request) => {}, {
fields: {
name: {
required: true,
error: "Name is required.",
},
},
});
Moralis.Cloud.beforeSave("Team", (request) => {}, {
fields: {
name: {
required: true,
error: "Name is required.",
},
},
});