some variable cleanup

pull/256/head
joeybloggs 9 years ago
parent d9bfef9fe0
commit dcdba454d7
  1. 19
      struct_level.go
  2. 11
      validator.go

@ -105,8 +105,11 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta
structFieldName = fieldName
}
v.slNs = append(v.slNs, fieldName...)
v.slStructNs = append(v.slStructNs, structFieldName...)
// v.slNs = append(v.slNs, fieldName...)
// v.slStructNs = append(v.slStructNs, structFieldName...)
v.ns = append(v.ns, fieldName...)
v.actualNs = append(v.actualNs, structFieldName...)
switch kind {
case reflect.Invalid:
@ -115,8 +118,8 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta
&fieldError{
tag: tag,
actualTag: tag,
ns: string(v.slNs),
structNs: string(v.slStructNs),
ns: string(v.ns),
structNs: string(v.actualNs),
field: fieldName,
structField: structFieldName,
// param: "",
@ -130,8 +133,8 @@ func (v *validate) ReportError(field interface{}, fieldName, structFieldName, ta
&fieldError{
tag: tag,
actualTag: tag,
ns: string(v.slNs),
structNs: string(v.slStructNs),
ns: string(v.ns),
structNs: string(v.actualNs),
field: fieldName,
structField: structFieldName,
value: fv.Interface(),
@ -153,8 +156,8 @@ func (v *validate) ReportValidationErrors(relativeNamespace, relativeStructNames
for i := 0; i < len(errs); i++ {
err = errs[i].(*fieldError)
err.ns = string(append(append(v.slNs, relativeNamespace...), err.ns...))
err.structNs = string(append(append(v.slStructNs, relativeStructNamespace...), err.structNs...))
err.ns = string(append(append(v.ns, relativeNamespace...), err.ns...))
err.structNs = string(append(append(v.actualNs, relativeStructNamespace...), err.structNs...))
v.errs = append(v.errs, err)
}

@ -6,11 +6,6 @@ import (
"strconv"
)
const (
arrayIndexFieldName = "%s" + leftBracket + "%d" + rightBracket
mapIndexFieldName = "%s" + leftBracket + "%v" + rightBracket
)
// per validate contruct
type validate struct {
v *Validate
@ -26,8 +21,6 @@ type validate struct {
// StructLevel & FieldLevel fields
slflParent reflect.Value
slCurrent reflect.Value
slNs []byte
slStructNs []byte
flField reflect.Value
flParam string
}
@ -75,8 +68,8 @@ func (v *validate) validateStruct(parent reflect.Value, current reflect.Value, t
v.slflParent = parent
v.slCurrent = current
v.slNs = ns
v.slStructNs = structNs
v.ns = ns
v.actualNs = structNs
cs.fn(v)
}

Loading…
Cancel
Save