Skip to content

Commit f8a081f

Browse files
fluff-upDean Karn
authored andcommitted
Added the function GetTag.
The function returns the name of the tag on which the function was called.
1 parent e73ec5f commit f8a081f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

field_level.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import "reflect"
55
// FieldLevel contains all the information and helper functions
66
// to validate a field
77
type FieldLevel interface {
8-
98
// returns the top level struct, if any
109
Top() reflect.Value
1110

@@ -26,6 +25,8 @@ type FieldLevel interface {
2625
// returns param for validation against current field
2726
Param() string
2827

28+
GetTag() string
29+
2930
// ExtractType gets the actual underlying type of field value.
3031
// It will dive into pointers, customTypes and return you the
3132
// underlying value and it's kind.
@@ -73,6 +74,11 @@ func (v *validate) FieldName() string {
7374
return v.cf.altName
7475
}
7576

77+
// GetTag returns the tag name of field
78+
func (v *validate) GetTag() string {
79+
return v.ct.tag
80+
}
81+
7682
// StructFieldName returns the struct field's name
7783
func (v *validate) StructFieldName() string {
7884
return v.cf.name

0 commit comments

Comments
 (0)