Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0.4
v2.0.5
4 changes: 4 additions & 0 deletions flesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"time"
)

func NewFlesh(thing interface{}) Flesh {
return &figFlesh{Flesh: thing}
}

func (flesh *figFlesh) ToString() string {
f, _ := toString(flesh.Flesh)
return f
Expand Down
8 changes: 8 additions & 0 deletions flesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import (
"github.com/stretchr/testify/assert"
)

func TestNewFlesh(t *testing.T) {
assert.NotNil(t, NewFlesh(t.Name()))
assert.Equal(t, t.Name(), NewFlesh(t.Name()).ToString())
assert.Equal(t, 0, NewFlesh(t.Name()).ToInt())
assert.Equal(t, map[string]string{}, NewFlesh(t.Name()).ToMap())
assert.Equal(t, []string{t.Name()}, NewFlesh(t.Name()).ToList())
}

func TestFleshInterface(t *testing.T) {
t.Run("Is", func(t *testing.T) {
t.Run("Map", func(t *testing.T) {
Expand Down
16 changes: 16 additions & 0 deletions validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,36 @@ func (tree *figTree) validateAll() error {
if fruit != nil && validator != nil {
var val interface{}
switch v := fruit.Flesh.Flesh.(type) {
case int:
val = v
case *int:
val = *v
case int64:
val = v
case *int64:
val = *v
case float64:
val = v
case *float64:
val = *v
case string:
val = v
case *string:
val = *v
case bool:
val = v
case *bool:
val = *v
case time.Duration:
val = v
case *time.Duration:
val = *v
case ListFlag:
val = v.values
case *ListFlag:
val = *v.values
case MapFlag:
val = v.values
case *MapFlag:
val = *v.values
}
Expand Down
Loading