jeudi 21 novembre 2019

Can I set default max length for string fields in struct?

I have multiple structs in my application using golang. Some fields in a struct have maxsize tags, some does not have. for e.g:

type structone struct {
  fieldone string `valid:MaxSize(2)`
  fieldtwo string 
}

type structtwo struct {
  fieldone string `valid:MaxSize(2)`
  fieldtwo string 
}

So I want to set default maxsize for all fields, if does not contain any valid max size tags in run time. Is it possible? Can somebody help.





Aucun commentaire:

Enregistrer un commentaire