mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
Update validator.v8 升级为 validator.v9
This commit is contained in:
@@ -1,18 +1,5 @@
|
||||
package param_bind
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"go-gin-api/app/controller/param_verify"
|
||||
"gopkg.in/go-playground/validator.v8"
|
||||
)
|
||||
|
||||
type ProductAdd struct {
|
||||
Name string `form:"name" json:"name" binding:"required,NameValid"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 绑定验证器
|
||||
if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
|
||||
v.RegisterValidation("NameValid", param_verify.NameValid)
|
||||
}
|
||||
Name string `form:"name" json:"name" validate:"required,NameValid"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user