asaskevich / govalidator

[Go] Package of validators and sanitizers for strings, numerics, slices and structs
MIT License
6.02k stars 556 forks source link

Can nested struct fields be given different criteria when used more than once? #387

Open RegProctor opened 4 years ago

RegProctor commented 4 years ago

Let's suppose that in the below I wanted Time to be validate:"min=10,max=20" when used as WriteTimeout and validate:"min=5,max=10" when used as ReadTimeout. How would you set the tags to do this if it's possible?

type DatabaseConfig struct {
    WriteTimeout     TimeConfig
    ReadTimeout      TimeConfig
}
type TimeConfig struct {
    String   string
    Time     int
}
sergeyglazyrindev commented 2 years ago

Hello guys! I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back Link to my repo: create issue there and we'll discuss it.