Skip to content

Commit

Permalink
chore: Log an error if a non-64 datatype is used. (#270)
Browse files Browse the repository at this point in the history
* Log an error if a non-64 datatype is used.

* missed int
  • Loading branch information
JamieSinn authored Sep 10, 2024
1 parent 0cf4f14 commit 160fd50
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion bucketing/segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bucketing

import (
"fmt"
"github.com/devcyclehq/go-server-sdk/v2/util"
"math"
"regexp"
"strings"
Expand Down Expand Up @@ -57,7 +58,30 @@ func checkCustomData(filter *CustomDataFilter, data map[string]interface{}, clie
} else {
dataValue = data[filter.DataKey]
}

isNot64Bit := false
switch dataValue.(type) {
case uint8:
isNot64Bit = true
case uint16:
isNot64Bit = true
case uint32:
isNot64Bit = true
case uint:
isNot64Bit = true
case int8:
isNot64Bit = true
case int16:
isNot64Bit = true
case int32:
isNot64Bit = true
case int:
isNot64Bit = true
case float32:
isNot64Bit = true
}
if isNot64Bit {
util.Errorf("Custom data key %s is not a 64 bit type. Please use a 64 bit type", filter.DataKey)
}
if operator == "exist" {
return checkValueExists(dataValue)
} else if operator == "!exist" {
Expand All @@ -68,6 +92,7 @@ func checkCustomData(filter *CustomDataFilter, data map[string]interface{}, clie
} else {
return checkStringsFilter(v, filter.UserFilter)
}

} else if _, ok := dataValue.(float64); ok && filter.DataKeyType == "Number" {
return checkNumbersFilterJSONValue(dataValue, filter.UserFilter)
} else if v, ok := dataValue.(bool); ok && filter.DataKeyType == "Boolean" {
Expand Down

0 comments on commit 160fd50

Please sign in to comment.