From a64ce2feb1e612797a0c2beeedc9bcb4cc6909fe Mon Sep 17 00:00:00 2001
From: Michael Jerger <michael.jerger@meissa-gmbh.de>
Date: Fri, 22 Dec 2023 14:20:30 +0100
Subject: [PATCH] removed resolved todos

---
 models/forgefed/actor.go           |  5 ++---
 modules/validation/helpers.go      | 21 -----------------
 modules/validation/validateable.go | 36 +++++++++++++++++-------------
 3 files changed, 22 insertions(+), 40 deletions(-)

diff --git a/models/forgefed/actor.go b/models/forgefed/actor.go
index ae4473b6e6..14804b3123 100644
--- a/models/forgefed/actor.go
+++ b/models/forgefed/actor.go
@@ -68,7 +68,7 @@ func NewPersonId(uri string, source string) (PersonId, error) {
 	//if !validation.IsValidExternalURL(uri) {
 	//	return PersonId{}, fmt.Errorf("uri %s is not a valid external url", uri)
 	//}
-	validatedUri, err := url.ParseRequestURI(uri) // ToDo: Why no err treatment at this place?
+	validatedUri, err := url.ParseRequestURI(uri)
 	if err != nil {
 		return PersonId{}, err
 	}
@@ -87,13 +87,12 @@ func NewPersonId(uri string, source string) (PersonId, error) {
 	return personId, nil
 }
 
-// TODO: tbd how an which parts can be generalized
 func NewRepositoryId(uri string, source string) (RepositoryId, error) {
 	if !validation.IsAPIURL(uri) {
 		return RepositoryId{}, fmt.Errorf("uri %s is not a valid repo url on this host %s", uri, setting.AppURL+"api")
 	}
 
-	validatedUri, err := url.ParseRequestURI(uri) // ToDo: Why no err treatment at this place?
+	validatedUri, err := url.ParseRequestURI(uri)
 	if err != nil {
 		return RepositoryId{}, err
 	}
diff --git a/modules/validation/helpers.go b/modules/validation/helpers.go
index 032c996fb5..567ad867fe 100644
--- a/modules/validation/helpers.go
+++ b/modules/validation/helpers.go
@@ -4,7 +4,6 @@
 package validation
 
 import (
-	"fmt"
 	"net"
 	"net/url"
 	"regexp"
@@ -135,23 +134,3 @@ func IsValidUsername(name string) bool {
 
 	return validUsernamePatternWithoutDots.MatchString(name) && !invalidUsernamePattern.MatchString(name)
 }
-
-func ValidateNotEmpty(value string, fieldName string) []string {
-	if value == "" {
-		return []string{fmt.Sprintf("Field %v may not be empty", fieldName)}
-	}
-	return []string{}
-}
-
-func ValidateOneOf(value string, allowed []string) []string {
-	for _, allowedElem := range allowed {
-		if value == allowedElem {
-			return []string{}
-		}
-	}
-	return []string{fmt.Sprintf("Value %v is not contained in allowed values [%v]", value, allowed)}
-}
-
-func ValidateSuffix(str, suffix string) bool {
-	return strings.HasSuffix(str, suffix)
-}
diff --git a/modules/validation/validateable.go b/modules/validation/validateable.go
index 71b3cb9687..0bf16fd72b 100644
--- a/modules/validation/validateable.go
+++ b/modules/validation/validateable.go
@@ -8,23 +8,12 @@ import (
 	"strings"
 )
 
-/*
-type ValidationFunctions interface {
-	Validate() []string
-	IsValid() (bool, error)
-}
-
-type Validateable struct {
-	ValidationFunctions
-}
-*/
-
 type Validateable interface {
 	Validate() []string
 }
 
-func IsValid(v any) (bool, error) {
-	if err := Validate(v); len(err) > 0 {
+func IsValid(v Validateable) (bool, error) {
+	if err := v.Validate(); len(err) > 0 {
 		errString := strings.Join(err, "\n")
 		return false, fmt.Errorf(errString)
 	}
@@ -32,7 +21,22 @@ func IsValid(v any) (bool, error) {
 	return true, nil
 }
 
-func Validate(v any) []string {
-	var result = []string{}
-	return result
+func ValidateNotEmpty(value string, fieldName string) []string {
+	if value == "" {
+		return []string{fmt.Sprintf("Field %v may not be empty", fieldName)}
+	}
+	return []string{}
+}
+
+func ValidateOneOf(value string, allowed []string) []string {
+	for _, allowedElem := range allowed {
+		if value == allowedElem {
+			return []string{}
+		}
+	}
+	return []string{fmt.Sprintf("Value %v is not contained in allowed values [%v]", value, allowed)}
+}
+
+func ValidateSuffix(str, suffix string) bool {
+	return strings.HasSuffix(str, suffix)
 }