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 == "" {
errors.Name = "required"
}
if len(name) > maxLength {
} else if len(name) > maxLength {
errors.Name = fmt.Sprintf("%d characters too long", len(name)-maxLength)
}
if !regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(name) {
} else if !regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString(name) {
errors.Name = "only letters, numbers, _ and - allowed"
}