All checks were successful
Test / Create distribution (push) Successful in 37s
Test / Sandbox (push) Successful in 2m23s
Test / Hakurei (push) Successful in 3m9s
Test / Hpkg (push) Successful in 4m7s
Test / Sandbox (race detector) (push) Successful in 4m11s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m30s
These are free of the dispatcher from internal/app. This change relocates them into their own package. Signed-off-by: Ophestra <cat@gensokyo.uk>
13 lines
370 B
Go
13 lines
370 B
Go
package validate
|
|
|
|
import "regexp"
|
|
|
|
// nameRegex is the default NAME_REGEX value from adduser.
|
|
var nameRegex = regexp.MustCompilePOSIX(`^[a-zA-Z][a-zA-Z0-9_-]*\$?$`)
|
|
|
|
// IsValidUsername returns whether the argument is a valid username.
|
|
func IsValidUsername(username string) bool {
|
|
return len(username) < Sysconf(SC_LOGIN_NAME_MAX) &&
|
|
nameRegex.MatchString(username)
|
|
}
|