github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/validators/username.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package validators 4 5 import "regexp" 6 7 const ( 8 // UsernamePattern : Regular expression of username. 9 UsernamePattern = `^[a-zA-](([\._\-][a-z0-9])|[a-z0-9]){0,62}$` 10 ) 11 12 // ValidateUsername use to validate a username string. 13 func ValidateUsername(username string) bool { 14 match, _ := regexp.MatchString(UsernamePattern, username) 15 return match 16 }