New
This commit is contained in:
20
internal/utils/validators.go
Normal file
20
internal/utils/validators.go
Normal file
@@ -0,0 +1,20 @@
|
||||
// Filename: internal/utils/validators.go
|
||||
package utils
|
||||
|
||||
import "regexp"
|
||||
|
||||
const MaxGroupNameLength = 32
|
||||
|
||||
// groupNameRegex validates that a group name consists only of lowercase letters, numbers, and hyphens.
|
||||
var groupNameRegex = regexp.MustCompile(`^[a-z0-9-]+$`)
|
||||
|
||||
// IsValidGroupName checks if the provided string is a valid group name.
|
||||
func IsValidGroupName(name string) bool {
|
||||
if name == "" {
|
||||
return false
|
||||
}
|
||||
if len(name) > MaxGroupNameLength {
|
||||
return false
|
||||
}
|
||||
return groupNameRegex.MatchString(name)
|
||||
}
|
||||
Reference in New Issue
Block a user