diff --git a/config/struct.go b/config/struct.go index 90d0b30aba2865e17488f742ef618569c01e02c7..f52c44b08c5a2e3d962248d6b7b031256cc0929a 100644 --- a/config/struct.go +++ b/config/struct.go @@ -24,7 +24,15 @@ func Load(prefix string, configPtr interface{}) error { return errors.Errorf("%T is not &struct", configPtr) } v := reflect.ValueOf(configPtr) - return load(prefix, t.Elem(), v.Elem()) + if err := load(prefix, t.Elem(), v.Elem()); err != nil { + return errors.Wrapf(err, "failed to load config with prefix %s", prefix) + } + if validator, ok := configPtr.(Validator); ok { + if err := validator.Validate(); err != nil { + return errors.Wrapf(err, "invalid config with prefix %s", prefix) + } + } + return nil } type nameValue struct {