Skip to content

Bug: FE presents undetailed error message for username validation #1693

Closed
@greyscaled

Description

@greyscaled

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

169904635-8063880a-6d28-45b1-836c-cce8ce82bc48

Notes

The Yup validation needs improvements here:

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:

Username string `json:"username" validate:"required,username"`

Which is defined here:

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)
})

usernameRegex = regexp.MustCompile("^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$")

Metadata

Metadata

Assignees

Labels

siteArea: frontend dashboard

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions