mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-18 16:01:18 +00:00
19 lines
305 B
Go
19 lines
305 B
Go
package utils
|
|
|
|
import "regexp"
|
|
|
|
func IsValidJSONKey(key string) bool {
|
|
const maxKeyLength = 255
|
|
if len(key) == 0 || len(key) > maxKeyLength {
|
|
return false
|
|
}
|
|
matched, err := regexp.MatchString(`^[a-zA-Z0-9_]+$`, key)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
if !matched {
|
|
return false
|
|
}
|
|
return true
|
|
}
|