diff --git a/descriptor.go b/descriptor.go index 55c7983..da00118 100644 --- a/descriptor.go +++ b/descriptor.go @@ -97,6 +97,8 @@ type ( DefaultValue struct { Value interface{} } + + ValueGenerator func(i interface{}) (object interface{}, ok bool) ) var Root = RootAsPath{} @@ -265,6 +267,11 @@ func (dv DefaultValue) ExtractObject(interface{}) (object interface{}, ok bool) return dv.Value, true } +func (vg ValueGenerator) ExtractObject(data interface{}) (object interface{}, ok bool) { + object, ok = vg(data) + return +} + func (vs ValueSources) ExtractObject(data interface{}) (object interface{}, ok bool) { for _, valueSource := range vs { if valueSource == nil {