remove unused & fix wording

This commit is contained in:
Michael Jerger 2024-05-01 15:23:39 +02:00
parent 87036ec719
commit 715ff0eb7f
3 changed files with 3 additions and 7 deletions

View file

@ -47,12 +47,12 @@ func (like ForgeLike) Validate() []string {
result = append(result, validation.ValidateNotEmpty(string(like.Type), "type")...) result = append(result, validation.ValidateNotEmpty(string(like.Type), "type")...)
result = append(result, validation.ValidateOneOf(string(like.Type), []any{"Like"}, "type")...) result = append(result, validation.ValidateOneOf(string(like.Type), []any{"Like"}, "type")...)
if like.Actor == nil { if like.Actor == nil {
result = append(result, "Actor my not be nil.") result = append(result, "Actor should not be nil.")
} else { } else {
result = append(result, validation.ValidateNotEmpty(like.Actor.GetID().String(), "actor")...) result = append(result, validation.ValidateNotEmpty(like.Actor.GetID().String(), "actor")...)
} }
if like.Object == nil { if like.Object == nil {
result = append(result, "Object my not be nil.") result = append(result, "Object should not be nil.")
} else { } else {
result = append(result, validation.ValidateNotEmpty(like.Object.GetID().String(), "object")...) result = append(result, validation.ValidateNotEmpty(like.Object.GetID().String(), "object")...)
} }

View file

@ -66,7 +66,7 @@ func TestActorIdValidation(t *testing.T) {
sut.Host = "an.other.host" sut.Host = "an.other.host"
sut.Port = "" sut.Port = ""
sut.UnvalidatedInput = "https://an.other.host/api/v1/activitypub/user-id/" sut.UnvalidatedInput = "https://an.other.host/api/v1/activitypub/user-id/"
if sut.Validate()[0] != "Field userId should not be empty" { if sut.Validate()[0] != "userId should not be empty" {
t.Errorf("validation error expected but was: %v\n", sut.Validate()) t.Errorf("validation error expected but was: %v\n", sut.Validate())
} }

View file

@ -65,7 +65,3 @@ func ValidateOneOf(value any, allowed []any, name string) []string {
} }
return []string{fmt.Sprintf("Value %v is not contained in allowed values %v", value, allowed)} 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)
}