diff --git a/each.go b/each.go index 2cc7253..8eb022c 100644 --- a/each.go +++ b/each.go @@ -78,7 +78,7 @@ func (r EachRule) getInterface(value reflect.Value) interface{} { if value.IsNil() { return nil } - return value.Elem().Interface() + return value.Interface() default: return value.Interface() } diff --git a/each_test.go b/each_test.go index 4199afd..731059e 100644 --- a/each_test.go +++ b/each_test.go @@ -72,3 +72,16 @@ func TestEachWithContext(t *testing.T) { assertError(t, test.err, err, test.tag) } } + +func TestEachAndBy(t *testing.T) { + var byAddr bool + var s string + Each(By(func(v interface{}) error { + _, byAddr = v.(*string) + return nil + })).Validate([]*string{&s}) + + if !byAddr { + t.Fatal("slice of pointers does not get passed to `By` function by ref") + } +}