MCPcopy Index your code
hub / github.com/coder/coder / DisplayNameValid

Function DisplayNameValid

codersdk/name.go:75–87  ·  view source on GitHub ↗

DisplayNameValid returns whether the input string is a valid template display name.

(str string)

Source from the content-addressed store, hash-verified

73
74// DisplayNameValid returns whether the input string is a valid template display name.
75func DisplayNameValid(str string) error {
76 if len(str) == 0 {
77 return nil // empty display_name is correct
78 }
79 if len(str) > 64 {
80 return xerrors.New("must be <= 64 characters")
81 }
82 matched := templateDisplayName.MatchString(str)
83 if !matched {
84 return xerrors.New("must be alphanumeric with spaces")
85 }
86 return nil
87}
88
89// UserRealNameValid returns whether the input string is a valid real user name.
90func UserRealNameValid(str string) error {

Callers 3

initFunction · 0.92
groupCreateMethod · 0.92

Calls 1

NewMethod · 0.65

Tested by 1