-
Notifications
You must be signed in to change notification settings - Fork 20
/
field_level.go
52 lines (41 loc) · 1.2 KB
/
field_level.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mold
import "reflect"
// FieldLevel represents the interface for field level modifier function
type FieldLevel interface {
// Transformer represents a subset of the current *Transformer that is executing the current transformation.
Transformer() Transform
//
// Parent returns the top level parent of the current value return by Field()
//
// This is used primarily for having the ability to nil out pointer type values.
//
// NOTE: that is there are several layers of abstractions eg. interface{} of interface{} of interface{} this
// function returns the first interface{}
//
Parent() reflect.Value
// Field returns the current field value being modified.
Field() reflect.Value
// Param returns the param associated wth the given function modifier.
Param() string
}
var (
_ FieldLevel = (*fieldLevel)(nil)
)
type fieldLevel struct {
transformer *Transformer
parent reflect.Value
current reflect.Value
param string
}
func (f fieldLevel) Transformer() Transform {
return f.transformer
}
func (f fieldLevel) Parent() reflect.Value {
return f.parent
}
func (f fieldLevel) Field() reflect.Value {
return f.current
}
func (f fieldLevel) Param() string {
return f.param
}