Skip to content

Commit

Permalink
check min max
Browse files Browse the repository at this point in the history
  • Loading branch information
cadyrov committed Apr 23, 2020
1 parent d7770ff commit b5e8983
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions minmax.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,30 @@ func (r *ThresholdRule) Validate(value interface{}) ExternalError {

default:
sliceHeaders, ok := value.([]multipart.FileHeader)
if !ok {
return NewExternalError(fmt.Errorf("type not supported: %v", rv.Type()), 1000)
}
var sum int64
for i := range sliceHeaders {
sum += sliceHeaders[i].Size
}
v, err := ToUint(sum)
if err != nil {
return NewExternalError(err, 1000)
if ok {
var sum int64
for i := range sliceHeaders {
sum += sliceHeaders[i].Size
}
v, err := ToUint(sum)
if err != nil {
return NewExternalError(err, 1000)
}
if r.compareUint(rv.Uint(), v) {
return nil
}
}
if r.compareUint(rv.Uint(), v) {
return nil
header, ok := value.(multipart.FileHeader)
if ok {
v, err := ToUint(header.Size)
if err != nil {
return NewExternalError(err, 1000)
}
if r.compareUint(rv.Uint(), v) {
return nil
}
}
return NewExternalError(fmt.Errorf("type not supported: %v", rv.Type()), 1000)
}

return NewExternalError(errors.New(r.message), 1000)
Expand Down

0 comments on commit b5e8983

Please sign in to comment.