From b009996c4a05b678574620aa8803b56af390f0ed Mon Sep 17 00:00:00 2001 From: Dean Karn Date: Sun, 19 Jul 2015 21:47:54 -0400 Subject: [PATCH 1/2] Update README.md update badge to proper branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4da807..96aa669 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Package validator ================ [![Join the chat at https://gitter.im/bluesuncorp/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/bluesuncorp/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/487374/badge.svg)](https://semaphoreci.com/joeybloggs/validator) +[![Build Status](https://semaphoreci.com/api/v1/projects/ec20115f-ef1b-4c7d-9393-cc76aba74eb4/487383/badge.svg)](https://semaphoreci.com/joeybloggs/validator) [![Coverage Status](https://coveralls.io/repos/bluesuncorp/validator/badge.svg?branch=v6)](https://coveralls.io/r/bluesuncorp/validator?branch=v6) [![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v6?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v6) From cdc48b4f9037d45c3a1fb8bbbfc870e47aa04c6f Mon Sep 17 00:00:00 2001 From: joeybloggs Date: Mon, 20 Jul 2015 08:45:29 -0400 Subject: [PATCH 2/2] Fix Bug in Ptr tests --- validator.go | 5 ++--- validator_test.go | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) 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())