Skip to content

Commit

Permalink
added negative number test
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Jun 26, 2023
1 parent 2e8e835 commit edd2eaa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/rest/multi_binder.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func normalizeMultipartValue(raw string) any {
case "false":
return false
default:
if raw[0] >= '0' && raw[0] <= '9' {
if raw[0] == '-' || (raw[0] >= '0' && raw[0] <= '9') {
if v, err := cast.ToFloat64E(raw); err == nil {
return v
}
Expand Down
4 changes: 2 additions & 2 deletions tools/rest/multi_binder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func TestBindBody(t *testing.T) {
url.Values{
"string": []string{"str"},
"stings": []string{"str1", "str2"},
"number": []string{"123"},
"number": []string{"-123"},
"numbers": []string{"123", "456"},
"bool": []string{"true"},
"bools": []string{"true", "false"},
}.Encode(),
),
echo.MIMEApplicationForm,
`{"bool":true,"bools":["true","false"],"number":123,"numbers":["123","456"],"stings":["str1","str2"],"string":"str"}`,
`{"bool":true,"bools":["true","false"],"number":-123,"numbers":["123","456"],"stings":["str1","str2"],"string":"str"}`,
false,
},
}
Expand Down

0 comments on commit edd2eaa

Please sign in to comment.