examples
examples copied to clipboard
Might be a bug in the example custom-validation
Hi, in the example Custom validators,
(https://github.com/gin-gonic/examples/blob/3a0d22aa344fcf014612f43f5bf21f9c9997fd67/custom-validation/server.go#L32)
v, ok := binding.Validator.Engine().(*validator.Validate)
returns v=nil and ok=false on my machine. Therefore the validator bookableDate
would not be registered.
Environment: Windows 10 Go 1.13 github.com/gin-gonic/gin v1.5.0 github.com/go-playground/validator/v10 v10.2.0
I encountered the same problem
due to [email protected] import gopkg.in/go-playground/validator.v9 so I solved this problem like this: custom-validation/server.go
//"github.com/go-playground/validator/v10"
"gopkg.in/go-playground/validator.v9"
...
CheckIn time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
it works.
thank you replay发自我的华为手机-------- 原始邮件 --------发件人: 陈圆 [email protected]日期: 2020年3月10日周二 傍晚5:30收件人: gin-gonic/examples [email protected]抄送: burningceramicsinmesary [email protected], Comment [email protected]主 题: Re: [gin-gonic/examples] Might be a bug in the example custom-validation (#29)due to [email protected] import gopkg.in/go-playground/validator.v9 so I solved this problem like this: custom-validation/server.go //"github.com/go-playground/validator/v10" "gopkg.in/go-playground/validator.v9"
...
CheckIn time.Time form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"
it works.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
@dasheyuan Can you please post a more details?
Update: nvm, thanks!