mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 06:03:51 +03:00
Implement and use Validatable interface
This commit is contained in:
parent
235ed7cd1e
commit
3d2b5115ad
2 changed files with 6 additions and 2 deletions
|
@ -6,6 +6,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Validatable interface {
|
||||||
|
Validate() error
|
||||||
|
}
|
||||||
|
|
||||||
type ActorID struct {
|
type ActorID struct {
|
||||||
schema string
|
schema string
|
||||||
userId string
|
userId string
|
||||||
|
@ -15,7 +19,7 @@ type ActorID struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Align validation-api to example from dda-devops-build
|
// TODO: Align validation-api to example from dda-devops-build
|
||||||
func (a ActorID) ValidateActorID() error {
|
func (a ActorID) Validate() error {
|
||||||
|
|
||||||
if a.schema == "" || a.host == "" {
|
if a.schema == "" || a.host == "" {
|
||||||
return fmt.Errorf("the actor ID was not valid: Invalid Schema or Host")
|
return fmt.Errorf("the actor ID was not valid: Invalid Schema or Host")
|
||||||
|
|
|
@ -96,7 +96,7 @@ func RepositoryInbox(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the ActorData Struct valid?
|
// Is the ActorData Struct valid?
|
||||||
err = actor.ValidateActorID()
|
err = actor.Validate()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in a new issue