Fix error order

This commit is contained in:
ekzyis 2024-09-11 12:28:46 +02:00
parent e868f91f84
commit 6e40ef6f54
1 changed files with 2 additions and 6 deletions

View File

@ -33,13 +33,9 @@ func HandleUserEdit(sc context.Context) echo.HandlerFunc {
if name == "" { if name == "" {
errors.Name = "required" errors.Name = "required"
} } else if len(name) > maxLength {
if len(name) > maxLength {
errors.Name = fmt.Sprintf("%d characters too long", len(name)-maxLength) errors.Name = fmt.Sprintf("%d characters too long", len(name)-maxLength)
} } else if !regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(name) {
if !regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(name) {
errors.Name = "only letters, numbers, _ and - allowed" errors.Name = "only letters, numbers, _ and - allowed"
} }