validator icon indicating copy to clipboard operation
validator copied to clipboard

default value

Open linsijia1002 opened this issue 3 years ago • 1 comments

  • [ ] I have looked at the documentation here first?
  • [ ] I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

gin version:v1.7.7 validator: v10

Issue, Question or Enhancement:

How can i set a default to a field when it no passed?

Code sample, to showcase or reproduce:

type User struct {
	FullName	string     `json:"FullName"       binding:"(set a default value when FullName no passed)"`
}


linsijia1002 avatar Nov 27 '21 06:11 linsijia1002

Hey @linsijia1002. This package only does validation. Setting default value is not part of the library, but you can try out something like this. https://github.com/gin-gonic/gin/issues/1052#issuecomment-515966643

zemzale avatar Jan 15 '22 16:01 zemzale