package lib import "regexp" var HandleRegex = regexp.MustCompile("^[a-z0-9_]+(-[a-z0-9_]+)*$") const HandleMinLength = 3 const HandleMaxLength = 30 // validates a handle. func ValidateHandle(s string) bool { // check if the format is correct using the regex if !HandleRegex.MatchString(s) { return false } // length constraint? length := len(s) if length < HandleMinLength || length > HandleMaxLength { return false } return true }