Skip to content

Commit

Permalink
style: fixes issues highlighted in review
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrltrent committed Jun 22, 2023
1 parent 570d26b commit 7a884d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
12 changes: 2 additions & 10 deletions features/schools/unwatch_school.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"confesi/lib/response"
"confesi/lib/utils"
"confesi/lib/validation"
"fmt"
"net/http"

"firebase.google.com/go/auth"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
)

func (h *handler) unwatchSchool(c *gin.Context, token *auth.Token, req validation.WatchSchool) error {
Expand All @@ -29,14 +27,8 @@ func (h *handler) handleUnwatchSchool(c *gin.Context) {
// extract request
var req validation.WatchSchool

// create validator
validator := validator.New()

binding := &validation.DefaultBinding{
Validator: validator,
}
if err := binding.Bind(c.Request, &req); err != nil {
response.New(http.StatusBadRequest).Err(fmt.Sprintf("failed validation: %v", err)).Send(c)
err := utils.New(c).Validate(&req)
if err != nil {
return
}

Expand Down
12 changes: 2 additions & 10 deletions features/schools/watch_school.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ import (
"confesi/lib/utils"
"confesi/lib/validation"
"errors"
"fmt"
"net/http"

"firebase.google.com/go/auth"
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"github.com/jackc/pgx/v5/pgconn"
)

Expand Down Expand Up @@ -45,14 +43,8 @@ func (h *handler) handleWatchSchool(c *gin.Context) {
// extract request
var req validation.WatchSchool

// create validator
validator := validator.New()

binding := &validation.DefaultBinding{
Validator: validator,
}
if err := binding.Bind(c.Request, &req); err != nil {
response.New(http.StatusBadRequest).Err(fmt.Sprintf("failed validation: %v", err)).Send(c)
err := utils.New(c).Validate(&req)
if err != nil {
return
}

Expand Down

0 comments on commit 7a884d9

Please sign in to comment.