DisplayNameValid returns whether the input string is a valid template display name.
(str string)
| 73 | |
| 74 | // DisplayNameValid returns whether the input string is a valid template display name. |
| 75 | func 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. |
| 90 | func UserRealNameValid(str string) error { |