const (
MIN = 60 * 10
MAX = 60 * 24 * 24 * 30
)
type Item struct {
Seconds int `valid:"required,range(MIN|MAX)"`
}
func NewItem(seconds int) (*Item, error) {
item := &Item{
Seconds: seconds,
}
_, err := govalidator.ValidateStruct(item)
if err != nil {
return nil, fmt.Errorf(err.Error())
}
return item, nil
}
Seconds int `valid:"required,range(${MIN}|${MAX})"`