UserRealNameValid returns whether the input string is a valid real user name.
(str string)
| 88 | |
| 89 | // UserRealNameValid returns whether the input string is a valid real user name. |
| 90 | func UserRealNameValid(str string) error { |
| 91 | if len(str) > 128 { |
| 92 | return xerrors.New("must be <= 128 characters") |
| 93 | } |
| 94 | |
| 95 | if strings.TrimSpace(str) != str { |
| 96 | return xerrors.New("must not have leading or trailing whitespace") |
| 97 | } |
| 98 | return nil |
| 99 | } |
| 100 | |
| 101 | // GroupNameValid returns whether the input string is a valid group name. |
| 102 | func GroupNameValid(str string) error { |