Merge branch 'correct-error-order' into v9

pull/262/head v9.2.2
Dean Karn 8 years ago
commit 597f93b316
  1. 2
      README.md
  2. 8
      cache.go
  3. 6
      validator.go

@ -2,7 +2,7 @@ Package validator
================
<img align="right" src="https://raw.githubusercontent.com/go-playground/validator/v9/logo.png">
[![Join the chat at https://gitter.im/go-playground/validator](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/go-playground/validator?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![Project status](https://img.shields.io/badge/version-9.2.1-green.svg)
![Project status](https://img.shields.io/badge/version-9.2.2-green.svg)
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/validator/branches/v9/badge.svg)](https://semaphoreci.com/joeybloggs/validator)
[![Coverage Status](https://coveralls.io/repos/go-playground/validator/badge.svg?branch=v9&service=github)](https://coveralls.io/github/go-playground/validator?branch=v9)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/validator)](https://goreportcard.com/report/github.com/go-playground/validator)

@ -70,7 +70,7 @@ func (tc *tagCache) Set(key string, value *cTag) {
type cStruct struct {
name string
fields map[int]*cField
fields []*cField
fn StructLevelFunc
}
@ -108,7 +108,7 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
return cs
}
cs = &cStruct{name: sName, fields: make(map[int]*cField), fn: v.structLevelFuncs[typ]}
cs = &cStruct{name: sName, fields: make([]*cField, 0), fn: v.structLevelFuncs[typ]}
numFields := current.NumField()
@ -153,13 +153,13 @@ func (v *Validate) extractStructCache(current reflect.Value, sName string) *cStr
ctag = new(cTag)
}
cs.fields[i] = &cField{
cs.fields = append(cs.fields, &cField{
idx: i,
name: fld.Name,
altName: customName,
cTags: ctag,
namesEqual: fld.Name == customName,
}
})
}
v.structCache.Set(typ, cs)

@ -53,7 +53,11 @@ func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, t
// so if nil or if not nil and the structonly tag isn't present
if ct == nil || ct.typeof != typeStructOnly {
for _, f := range cs.fields {
var f *cField
for i := 0; i < len(cs.fields); i++ {
f = cs.fields[i]
if v.isPartial {

Loading…
Cancel
Save