Skip to content
Snippets Groups Projects
Commit 873b5d9c authored by ko_oler's avatar ko_oler
Browse files

fix

parent 8489e58d
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ var ( ...@@ -17,6 +17,7 @@ var (
ErrEmptyID = errors.New("empty ID") ErrEmptyID = errors.New("empty ID")
ErrNotValidID = errors.New("id contains invalid characters") ErrNotValidID = errors.New("id contains invalid characters")
ErrLongID = errors.New("id too long (max 64 symbols)") ErrLongID = errors.New("id too long (max 64 symbols)")
ErrEmptyName = errors.New("empty name")
ErrLongName = errors.New("name too long (max 256 symbols)") ErrLongName = errors.New("name too long (max 256 symbols)")
isValidID = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9-_]*$`).MatchString isValidID = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9-_]*$`).MatchString
) )
...@@ -41,7 +42,11 @@ func ValidateID(id string) error { ...@@ -41,7 +42,11 @@ func ValidateID(id string) error {
} }
func ValidateName(name string) error { func ValidateName(name string) error {
if len(name) > MaxLengthName { trimmedName := strings.TrimSpace(name)
if trimmedName == "" {
return ErrEmptyName
}
if len(trimmedName) > MaxLengthName {
return ErrLongName return ErrLongName
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment