Skip to content

Commit

Permalink
change err
Browse files Browse the repository at this point in the history
  • Loading branch information
cadyrov committed Sep 18, 2020
1 parent 20a05d2 commit 89b0cb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions date.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (r *DateRule) Min(min time.Time) *DateRule {
// Max sets the maximum date range. A zero value means skipping the maximum range validation.
func (r *DateRule) Max(max time.Time) *DateRule {
r.max = max

return r
}

Expand Down
7 changes: 2 additions & 5 deletions validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package validation

import (
"fmt"
"net/http"
"reflect"
"strconv"

Expand Down Expand Up @@ -83,7 +82,7 @@ func Validate(value interface{}, rules ...Rule) goerr.IError {

// validateMap validates a map of validatable elements
func validateMap(rv reflect.Value) goerr.IError {
errs := verror.NewErrStack()
errs := verror.NewErrStack("validationError")
for _, key := range rv.MapKeys() {
if mv := rv.MapIndex(key).Interface(); mv != nil {
if code, args := mv.(Validatable).Validate(); code != 0 {
Expand All @@ -92,15 +91,14 @@ func validateMap(rv reflect.Value) goerr.IError {
}
}
if len(errs.Stack) > 0 {
errs.IError = goerr.New("").HTTP(http.StatusBadRequest)
return errs
}
return nil
}

// validateMap validates a slice/array of validatable elements
func validateSlice(rv reflect.Value) goerr.IError {
errs := verror.NewErrStack()
errs := verror.NewErrStack("validationError")
l := rv.Len()
for i := 0; i < l; i++ {
if ev := rv.Index(i).Interface(); ev != nil {
Expand All @@ -110,7 +108,6 @@ func validateSlice(rv reflect.Value) goerr.IError {
}
}
if len(errs.Stack) > 0 {
errs.IError = goerr.New("").HTTP(http.StatusBadRequest)
return errs
}
return nil
Expand Down

0 comments on commit 89b0cb4

Please sign in to comment.