Skip to content
Snippets Groups Projects
Commit 54f9b6c0 authored by ko_oler's avatar ko_oler
Browse files

fix

parent 3665398c
No related branches found
No related tags found
No related merge requests found
......@@ -26,25 +26,27 @@ func GenerateNewID() string {
return xid.New().String()
}
func ValidateID(id string) error {
if strings.TrimSpace(id) == "" {
func ValidateID(id *string) error {
trimmedID := strings.TrimSpace(*id)
if trimmedID == "" {
return ErrEmptyID
}
if len(id) > MaxLengthID {
if len(trimmedID) > MaxLengthID {
return ErrLongID
}
if !isValidID(id) {
if !isValidID(trimmedID) {
return errors.WithDetail(ErrNotValidID, "must begin with latin letters and contain latin letters, numbers or '-', '_'")
}
return nil
}
func ValidateName(name string) error {
if strings.TrimSpace(name) == "" {
func ValidateName(name *string) error {
trimmedName := strings.TrimSpace(*name)
if trimmedName == "" {
return ErrEmptyName
}
if len(name) > MaxLengthName {
if len(trimmedName) > MaxLengthName {
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