From edd2eaae887005771840d8e934b1e6ab7b7ee812 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 26 Jun 2023 12:42:53 +0300 Subject: [PATCH] added negative number test --- tools/rest/multi_binder.go | 2 +- tools/rest/multi_binder_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/rest/multi_binder.go b/tools/rest/multi_binder.go index cd8f52ca..58c96560 100644 --- a/tools/rest/multi_binder.go +++ b/tools/rest/multi_binder.go @@ -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 } diff --git a/tools/rest/multi_binder_test.go b/tools/rest/multi_binder_test.go index 318e767b..d4592287 100644 --- a/tools/rest/multi_binder_test.go +++ b/tools/rest/multi_binder_test.go @@ -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, }, }