Skip to content

Commit

Permalink
let basecontroller binding could bind multiple tim
Browse files Browse the repository at this point in the history
gin-gonic/gin#1341
Signed-off-by: Toby Yan <[email protected]>
  • Loading branch information
toby1991 committed Mar 6, 2019
1 parent c93c09b commit 0ebd99a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion http/controller/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controller

import (
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"gopkg.in/go-playground/validator.v9"
"net/http"
)
Expand All @@ -13,7 +14,7 @@ type Controller interface {
type BaseController struct{}

func (bc *BaseController) Validate(c *gin.Context, _validator interface{}) bool {
if err := c.ShouldBindJSON(_validator); err != nil {
if err := c.ShouldBindWith(_validator, binding.JSON); err != nil {

_ = err.(validator.ValidationErrors)
//@todo translate
Expand Down

0 comments on commit 0ebd99a

Please sign in to comment.