aboutsummaryrefslogtreecommitdiff
path: root/utils/env/validator.go
blob: fa9b17ffb1c79a9e9e23b7029955334451708f76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package env

import (
	"fmt"
	"reflect"
)

func validateConfigInput(config any) (reflect.Value, reflect.Type, error) {
	v := reflect.ValueOf(config)
	if v.Kind() != reflect.Pointer || v.Elem().Kind() != reflect.Struct {
		return reflect.Value{}, nil, fmt.Errorf("config must be a pointer to struct")
	}
	elem := v.Elem()
	return elem, elem.Type(), nil
}