mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
31 lines
547 B
Go
31 lines
547 B
Go
|
package indexparamcheck
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
|
||
|
"github.com/milvus-io/milvus/internal/util/funcutil"
|
||
|
)
|
||
|
|
||
|
func CheckIntByRange(params map[string]string, key string, min, max int) bool {
|
||
|
valueStr, ok := params[key]
|
||
|
if !ok {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
value, err := strconv.Atoi(valueStr)
|
||
|
if err != nil {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return value >= min && value <= max
|
||
|
}
|
||
|
|
||
|
func CheckStrByValues(params map[string]string, key string, container []string) bool {
|
||
|
value, ok := params[key]
|
||
|
if !ok {
|
||
|
return false
|
||
|
}
|
||
|
|
||
|
return funcutil.SliceContain(container, value)
|
||
|
}
|