Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Might be a bug in the example custom-validation #29

Open
Tensorfengsheng1926 opened this issue Feb 18, 2020 · 4 comments
Open

Might be a bug in the example custom-validation #29

Tensorfengsheng1926 opened this issue Feb 18, 2020 · 4 comments

Comments

@Tensorfengsheng1926
Copy link

Hi, in the example Custom validators,
(

if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
)
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

@lkburning
Copy link

I encountered the same problem

@dasheyuan
Copy link

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.

@lkburning
Copy link

lkburning commented Mar 10, 2020 via email

@rahulnpadalkar
Copy link

rahulnpadalkar commented Mar 18, 2020

@dasheyuan Can you please post a more details?

Update: nvm, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants