Skip to content

Commit 7a8d2ca

Browse files
mike-zorndaveshanley
authored andcommitted
Eliminate enumCheck parameter
Only validate enums based on the provided item vs. the unparsed value.
1 parent 9b51ff1 commit 7a8d2ca

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

parameters/validation_functions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ func ValidateQueryArray(
127127
}
128128

129129
// check if the param is within an enum
130-
checkEnum := func(enumCheck, item string) {
130+
checkEnum := func(item string) {
131131
// check if the array param is within an enum
132132
if sch.Items.IsA() {
133133
itemsSch := sch.Items.A.Schema()
134134
if itemsSch.Enum != nil {
135135
matchFound := false
136136
for _, enumVal := range itemsSch.Enum {
137-
if strings.TrimSpace(enumCheck) == fmt.Sprint(enumVal.Value) {
137+
if strings.TrimSpace(item) == fmt.Sprint(enumVal.Value) {
138138
matchFound = true
139139
break
140140
}
@@ -159,7 +159,7 @@ func ValidateQueryArray(
159159
break
160160
}
161161
// will it blend?
162-
checkEnum(ef, item)
162+
checkEnum(item)
163163

164164
case helpers.Boolean:
165165
if _, err := strconv.ParseBool(item); err != nil {
@@ -180,7 +180,7 @@ func ValidateQueryArray(
180180
case helpers.String:
181181

182182
// will it float?
183-
checkEnum(ef, item)
183+
checkEnum(item)
184184
}
185185
}
186186
}

0 commit comments

Comments
 (0)