Skip to content

Commit

Permalink
Added the function GetTag.
Browse files Browse the repository at this point in the history
The function returns the name of the tag on which the function was called.
  • Loading branch information
fluff-up committed Nov 7, 2019
1 parent cd1bd58 commit b01869e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion field_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "reflect"
// FieldLevel contains all the information and helper functions
// to validate a field
type FieldLevel interface {

// returns the top level struct, if any
Top() reflect.Value

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

GetTag() string

// ExtractType gets the actual underlying type of field value.
// It will dive into pointers, customTypes and return you the
// underlying value and it's kind.
Expand Down Expand Up @@ -57,6 +58,11 @@ func (v *validate) FieldName() string {
return v.cf.altName
}

// GetTag returns the tag name of field
func (v *validate) GetTag() string {
return v.ct.tag
}

// StructFieldName returns the struct field's name
func (v *validate) StructFieldName() string {
return v.cf.name
Expand Down

0 comments on commit b01869e

Please sign in to comment.