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

ShouldBind File ? #1591

Closed
ghost opened this issue Oct 13, 2018 · 2 comments
Closed

ShouldBind File ? #1591

ghost opened this issue Oct 13, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Oct 13, 2018

  • go version: go1.11.1 windows/amd64
  • gin version (or commit ref): v1.4.0-dev
  • operating system: Windows 10 x64

I have a upload operation with more info. I use Should bind but not working.

// RegisterForm ...
type RegisterForm struct {
	FullName string                `form:"full_name" binding:"required"`
	Email    string                `form:"email" binding:"required"`
	Image    *multipart.FileHeader `form:"image" binding:"required"`
	Password string                `form:"password" binding:"required"`
}

and binding here.

        tmpForm := RegisterForm{}
	if err := ctx.ShouldBind(&tmpForm); err == nil {
                // .... 
	} else {
		fmt.Println(err.Error())
	}

Output:

Key: 'RegisterForm.Image' Error:Field validation for 'Image' failed on the 'required' tag

Request (Postman):
adsiz

@thinkerou
Copy link
Member

issue ref: #1263 and pr ref: #1264

@thinkerou
Copy link
Member

@ghost #1264 merged!

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

No branches or pull requests

1 participant