carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

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