-
Notifications
You must be signed in to change notification settings - Fork 952
Closed
Description
This is a spawn-off of #1689 (thanks @oxy 🎉)
Steps to Reproduce
See #1689
Expected
A helpful error message regarding what letters/characters/combinations the username accepts
Actual
An undetailed error message
Screenshot
Notes
The Yup validation needs improvements here:
username: Yup.string().trim(), |
This uses username
validation, which is a custom validator we have in our backend.
To source this, see that the struct has a username
tag here:
Line 57 in c465f8a
Username string `json:"username" validate:"required,username"` |
Which is defined here:
coder/coderd/httpapi/httpapi.go
Lines 34 to 47 in c465f8a
err := validate.RegisterValidation("username", func(fl validator.FieldLevel) bool { | |
f := fl.Field().Interface() | |
str, ok := f.(string) | |
if !ok { | |
return false | |
} | |
if len(str) > 32 { | |
return false | |
} | |
if len(str) < 1 { | |
return false | |
} | |
return usernameRegex.MatchString(str) | |
}) |
coder/coderd/httpapi/httpapi.go
Line 18 in c465f8a
usernameRegex = regexp.MustCompile("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$") |
Metadata
Metadata
Assignees
Labels
siteArea: frontend dashboardArea: frontend dashboard