Skip to content

Commit 450b609

Browse files
committed
fix: handle null string form value for update contact form
1 parent 971a433 commit 450b609

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cmd/contacts.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ func handleUpdateContact(r *fastglue.Request) error {
104104
avatarURL = string(v[0])
105105
}
106106

107+
// Set nulls to empty strings.
108+
if avatarURL == "null" {
109+
avatarURL = ""
110+
}
111+
if phoneNumberCallingCode == "null" {
112+
phoneNumberCallingCode = ""
113+
}
114+
if phoneNumber == "null" {
115+
phoneNumber = ""
116+
}
117+
107118
// Validate mandatory fields.
108119
if email == "" {
109120
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "email"), nil, envelope.InputError)

0 commit comments

Comments
 (0)