Merge pull request #119 from bluesuncorp/v6-development

V6 development
pull/154/head
Dean Karn 9 years ago
commit fd0f7cd349
  1. 2
      README.md
  2. 5
      validator.go
  3. 16
      validator_test.go

@ -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) [![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) [![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) [![GoDoc](https://godoc.org/gopkg.in/bluesuncorp/validator.v6?status.svg)](https://godoc.org/gopkg.in/bluesuncorp/validator.v6)

@ -254,10 +254,9 @@ func (v *Validate) traverseField(topStruct reflect.Value, currentStruct reflect.
return return
} }
tags := strings.Split(tag, tagSeparator) if len(tag) > 0 {
if len(tags) > 0 {
tags := strings.Split(tag, tagSeparator)
var param string var param string
vals := strings.SplitN(tags[0], tagKeySeparator, 2) vals := strings.SplitN(tags[0], tagKeySeparator, 2)

@ -229,6 +229,19 @@ func AssertError(t *testing.T, errs ValidationErrors, key, field, expectedTag st
EqualSkip(t, 2, val.Tag, expectedTag) 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) { func TestCommaAndPipeObfuscationValidation(t *testing.T) {
s := "My Name Is, |joeybloggs|" s := "My Name Is, |joeybloggs|"
@ -634,13 +647,12 @@ func TestArrayDiveValidation(t *testing.T) {
errs = validate.Struct(tmsp) errs = validate.Struct(tmsp)
NotEqual(t, errs, nil) 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][1].Name", "Name", "required")
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[0][2].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][1].Name", "Name", "required")
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[1][2].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][1].Name", "Name", "required")
AssertError(t, errs, "TestMultiDimensionalStructsPtr.Errs[2][2]", "Errs[2][2]", "")
// for full test coverage // for full test coverage
fmt.Sprint(errs.Error()) fmt.Sprint(errs.Error())

Loading…
Cancel
Save