Skip to content

Commit 8d5243c

Browse files
author
Joseph Rosso
committed
Added backend validation for poll title length
1 parent 7349bd5 commit 8d5243c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ func CreatePoll(c *gin.Context) {
139139
return
140140
}
141141

142+
// If title length exceeds 250 characters, return a bad request
143+
if len(c.PostForm("title")) > 250 {
144+
c.JSON(http.StatusBadRequest, gin.H{"error": "title length exceeds limit of 250 characters"})
145+
return
146+
}
147+
142148
quorumType := c.PostForm("quorumType")
143149

144150
quorum, err := strconv.ParseFloat(quorumType, 64)

0 commit comments

Comments
 (0)