diff --git a/validator.go b/validator.go index 6a527b2..781bea3 100644 --- a/validator.go +++ b/validator.go @@ -254,10 +254,9 @@ func (v *Validate) traverseField(topStruct reflect.Value, currentStruct reflect. return } - tags := strings.Split(tag, tagSeparator) - - if len(tags) > 0 { + if len(tag) > 0 { + tags := strings.Split(tag, tagSeparator) var param string vals := strings.SplitN(tags[0], tagKeySeparator, 2) diff --git a/validator_test.go b/validator_test.go index f9a042c..4021e86 100644 --- a/validator_test.go +++ b/validator_test.go @@ -229,6 +229,19 @@ func AssertError(t *testing.T, errs ValidationErrors, key, field, expectedTag st EqualSkip(t, 2, val.Tag, expectedTag) } +func TestDatePtrValidationIssueValidation(t *testing.T) { + + type Test struct { + LastViewed *time.Time + Reminder *time.Time + } + + test := &Test{} + + errs := validate.Struct(test) + Equal(t, errs, nil) +} + func TestCommaAndPipeObfuscationValidation(t *testing.T) { s := "My Name Is, |joeybloggs|" @@ -634,13 +647,12 @@ func TestArrayDiveValidation(t *testing.T) { errs = validate.Struct(tmsp) NotEqual(t, errs, nil) - Equal(t, len(errs), 6) + Equal(t, len(errs), 5) AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][1].Name", "Name", "required") AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][2].Name", "Name", "required") AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][1].Name", "Name", "required") AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][2].Name", "Name", "required") AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[2][1].Name", "Name", "required") - AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[2][2]", "Errs[2][2]", "") // for full test coverage fmt.Sprint(errs.Error())