krostar/config

Handle a Validate() method

Peltoche opened this issue · 0 comments

The idea would be to handle a Validate() method like the SetDefault().

This function would allow to parse the configuration before returning it and in case of error print a formatted response.

Example:

type Config struct {
   url string `yaml:"url`
}

func (c *Config) Validate() error {
  _, err := url.Parse(c.url)
 // If err != nil, the config.Load() method will return an error
 return err
}