Skip to content

Commit b01869e

Browse files
committed
Added the function GetTag.
The function returns the name of the tag on which the function was called.
1 parent cd1bd58 commit b01869e

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.
@@ -57,6 +58,11 @@ func (v *validate) FieldName() string {
5758
return v.cf.altName
5859
}
5960

61+
// GetTag returns the tag name of field
62+
func (v *validate) GetTag() string {
63+
return v.ct.tag
64+
}
65+
6066
// StructFieldName returns the struct field's name
6167
func (v *validate) StructFieldName() string {
6268
return v.cf.name

0 commit comments

Comments
 (0)