diff --git a/struct.go b/struct.go index 34afee8..9862287 100644 --- a/struct.go +++ b/struct.go @@ -53,11 +53,11 @@ func ValidateStruct(structPtr interface{}, fields ...*FieldRules) goerr.IError { for _, fr := range fields { fv := reflect.ValueOf(fr.fieldPtr) if fv.Kind() != reflect.Ptr { - return verror.NewGoerr(1002) + return verror.NewGoErr(1002) } ft := findStructField(value, fv) if ft == nil { - return verror.NewGoerr(1003) + return verror.NewGoErr(1003) } if err := Validate(fv.Elem().Interface(), fr.rules...); err != nil { if ft.Anonymous { diff --git a/validation.go b/validation.go index e4e0bf6..cc7f361 100644 --- a/validation.go +++ b/validation.go @@ -51,7 +51,7 @@ func Validate(value interface{}, rules ...Rule) goerr.IError { return nil } if code, args := rule.Validate(value); code != 0 { - return verror.NewGoerr(code, args...) + return verror.NewGoErr(code, args...) } } @@ -61,7 +61,7 @@ func Validate(value interface{}, rules ...Rule) goerr.IError { } if v, ok := value.(Validatable); ok { if code, args := v.Validate(); code != 0 { - return verror.NewGoerr(code, args...) + return verror.NewGoErr(code, args...) } return nil } @@ -87,7 +87,7 @@ func validateMap(rv reflect.Value) goerr.IError { for _, key := range rv.MapKeys() { if mv := rv.MapIndex(key).Interface(); mv != nil { if code, args := mv.(Validatable).Validate(); code != 0 { - errs.Stack[fmt.Sprintf("%v", key.Interface())] = verror.NewGoerr(code, args) + errs.Stack[fmt.Sprintf("%v", key.Interface())] = verror.NewGoErr(code, args) } } } @@ -105,7 +105,7 @@ func validateSlice(rv reflect.Value) goerr.IError { for i := 0; i < l; i++ { if ev := rv.Index(i).Interface(); ev != nil { if code, args := ev.(Validatable).Validate(); code != 0 { - errs.Stack[strconv.Itoa(i)] = verror.NewGoerr(code, args) + errs.Stack[strconv.Itoa(i)] = verror.NewGoErr(code, args) } } } diff --git a/verror/error.go b/verror/error.go index 01844fd..6b52e4b 100644 --- a/verror/error.go +++ b/verror/error.go @@ -130,10 +130,10 @@ func NewErrStack() ErrStack { } } -func NewGoerr(code int, args ...interface{}) goerr.IError { +func NewGoErr(code int, args ...interface{}) goerr.IError { errtxt, ok := mpErr[code] if !ok { errtxt = "UnknownError" } - return goerr.New(fmt.Sprintf(errtxt, args...)).Http(http.StatusBadRequest) + return goerr.New(fmt.Sprintf(errtxt, args...)).HTTP(http.StatusBadRequest) }