package domains import "regexp" // accountNameRe pins what an account NAME may be so it can live in a URL // path segment and a CLI flag: 1–63 characters of lowercase a-z, 0-9 and // hyphen, no leading or trailing hyphen. Names are still deliberately // non-unique (identity is the sqid); this constrains shape, not ownership. var accountNameRe = regexp.MustCompile(`^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$`) // ValidAccountName reports whether name is usable as an account name. // Applied at the edges where a human TYPES a name (console new-account // form, POST /auth/cli/accounts, `carlos accounts create`) — never at // auto-mint, where the personal account is named by keymail address and a // refusal would strand a signed-in user. func ValidAccountName(name string) bool { return accountNameRe.MatchString(name) }