From c8e64389a7802c6a5d6389bdeb3097395a59f76b Mon Sep 17 00:00:00 2001 From: setiadijoe Date: Wed, 23 Jun 2021 13:32:02 +0700 Subject: [PATCH] #57 update function isOrderValid --- endpoint/request.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/endpoint/request.go b/endpoint/request.go index 0e711e8..6174845 100644 --- a/endpoint/request.go +++ b/endpoint/request.go @@ -1,6 +1,8 @@ package endpoint import ( + "strings" + "github.com/go-ozzo/ozzo-validation/is" validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/sapawarga/userpost-service/helper" @@ -70,17 +72,6 @@ func validationImages(in []*Image) validation.RuleFunc { } } -var ordering = map[int]string{ - 0: "ASC", - 1: "DESC", -} - func isOrderValid(val string) bool { - for i := range ordering { - if ordering[i] == val { - return true - } - } - - return false + return strings.EqualFold(val, "ASC") || strings.EqualFold(val, "DESC") }