mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
28 lines
471 B
Go
28 lines
471 B
Go
|
package hook
|
||
|
|
||
|
import (
|
||
|
"reflect"
|
||
|
|
||
|
"github.com/mitchellh/mapstructure"
|
||
|
|
||
|
"github.com/zitadel/zitadel/internal/domain"
|
||
|
)
|
||
|
|
||
|
func StringToFeatureHookFunc() mapstructure.DecodeHookFuncType {
|
||
|
return func(
|
||
|
f reflect.Type,
|
||
|
t reflect.Type,
|
||
|
data interface{},
|
||
|
) (interface{}, error) {
|
||
|
if f.Kind() != reflect.String {
|
||
|
return data, nil
|
||
|
}
|
||
|
|
||
|
if t != reflect.TypeOf(domain.FeatureUnspecified) {
|
||
|
return data, nil
|
||
|
}
|
||
|
|
||
|
return domain.FeatureString(data.(string))
|
||
|
}
|
||
|
}
|