Skip to content

Commit cd0a6c8

Browse files
committed
added check to make sure that votes are not empty
1 parent 7931034 commit cd0a6c8

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,14 @@ func main() {
404404
return
405405
}
406406
}
407+
408+
// Make sure vote is not empty
409+
if len(vote.Options) == 0 {
410+
c.JSON(http.StatusBadRequest, gin.H{"error": "You did not rank any options"})
411+
return
412+
}
413+
414+
// Submit Vote
407415
database.CastRankedVote(c, &vote, &voter)
408416
} else {
409417
c.JSON(http.StatusInternalServerError, gin.H{"error": "Unknown Poll Type"})

0 commit comments

Comments
 (0)