@@ -25,18 +25,14 @@ type Transform interface {
2525// Func defines a transform function for use.
2626type Func func (ctx context.Context , fl FieldLevel ) error
2727
28- //
2928// StructLevelFunc accepts all values needed for struct level manipulation.
3029//
3130// Why does this exist? For structs for which you may not have access or rights to add tags too,
3231// from other packages your using.
33- //
3432type StructLevelFunc func (ctx context.Context , sl StructLevel ) error
3533
36- //
3734// InterceptorFunc is a way to intercept custom types to redirect the functions to be applied to an inner typ/value.
3835// eg. sql.NullString, the manipulation should be done on the inner string.
39- //
4036type InterceptorFunc func (current reflect.Value ) (inner reflect.Value )
4137
4238// Transformer is the base controlling object which contains
@@ -135,13 +131,11 @@ func (t *Transformer) RegisterStructLevel(fn StructLevelFunc, types ...interface
135131 }
136132}
137133
138- //
139134// RegisterInterceptor registers a new interceptor functions agains one or more types.
140135// This InterceptorFunc allows one to intercept the incoming to to redirect the application of modifications
141136// to an inner type/value.
142137//
143138// eg. sql.NullString
144- //
145139func (t * Transformer ) RegisterInterceptor (fn InterceptorFunc , types ... interface {}) {
146140 for _ , typ := range types {
147141 t .interceptors [reflect .TypeOf (typ )] = fn
@@ -263,6 +257,7 @@ func (t *Transformer) setByField(ctx context.Context, orig reflect.Value, ct *cT
263257 return
264258 }
265259 orig .Set (reflect .Indirect (newVal ))
260+ current , kind = t .extractType (orig )
266261 } else {
267262 if err = ct .fn (ctx , fieldLevel {
268263 transformer : t ,
0 commit comments