From 3beb3e9b703416285e884696efe163ba0384d4c1 Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Mon, 18 Nov 2024 04:11:01 -0500 Subject: [PATCH] validate funding needed amount --- pages/goals.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pages/goals.go b/pages/goals.go index 8098b76..e6d3e4f 100644 --- a/pages/goals.go +++ b/pages/goals.go @@ -57,9 +57,7 @@ func CreateGoal(c *gin.Context) { }) } - createdDate := time.Now() - updatedDate := time.Now() - fundingAmount, err := strconv.ParseFloat(fundingAmountStr, 64) + fundingAmount, err := strconv.ParseFloat(strings.Replace(fundingAmountStr, ",", "", -1), 64) if err != nil { fieldError := fmt.Errorf("invalid funding amount") @@ -70,6 +68,9 @@ func CreateGoal(c *gin.Context) { }) } + createdDate := time.Now() + updatedDate := time.Now() + _, err = dbClient.Exec(`INSERT INTO goals (name, description, learn_more_url, funding_amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?);`, name, description, learnMoreURL, fundingAmount, createdDate, updatedDate)