- Notifications
You must be signed in to change notification settings - Fork928
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 usesusername
validation, which is a custom validator we have in our backend.
To source this, see that the struct has ausername
tag here:
Line 57 inc465f8a
Usernamestring`json:"username" validate:"required,username"` |
Which is defined here:
coder/coderd/httpapi/httpapi.go
Lines 34 to 47 inc465f8a
err:=validate.RegisterValidation("username",func(fl validator.FieldLevel)bool { | |
f:=fl.Field().Interface() | |
str,ok:=f.(string) | |
if!ok { | |
returnfalse | |
} | |
iflen(str)>32 { | |
returnfalse | |
} | |
iflen(str)<1 { | |
returnfalse | |
} | |
returnusernameRegex.MatchString(str) | |
}) |
coder/coderd/httpapi/httpapi.go
Line 18 inc465f8a
usernameRegex=regexp.MustCompile("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$") |