Skip to content

Commit 0edd427

Browse files
Add payload validation to create-or-update-lead action
- Validate that at least one field is provided before making API call - Prevents 400 errors from Adversus API when empty payload is sent - Provides clear error message to users
1 parent 094ad7e commit 0edd427

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

components/adversus/actions/create-or-update-lead/create-or-update-lead.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ export default {
6666
...(this.additionalFields || {}),
6767
};
6868

69+
if (!Object.keys(data).length) {
70+
throw new Error("At least one field must be provided to create or update a lead. Please provide firstName, lastName, email, phone, or additionalFields.");
71+
}
72+
6973
const response = this.leadId
7074
? await this.adversus.updateLead(this.leadId, { data })
7175
: await this.adversus.createLead({ data });

0 commit comments

Comments
 (0)