mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 11:52:10 +00:00
introduce FI Factory
This commit is contained in:
parent
dabd773f6b
commit
ca5eaa8c6b
2 changed files with 16 additions and 9 deletions
|
@ -21,6 +21,18 @@ type FederationInfo struct {
|
|||
Updated timeutil.TimeStamp `xorm:"updated"`
|
||||
}
|
||||
|
||||
// Factory function for PersonID. Created struct is asserted to be valid
|
||||
func NewFederationInfo(nodeInfo NodeInfo, hostFqdn string) (FederationInfo, error) {
|
||||
result := FederationInfo{
|
||||
HostFqdn: hostFqdn,
|
||||
NodeInfo: nodeInfo,
|
||||
}
|
||||
if valid, err := validation.IsValid(result); !valid {
|
||||
return FederationInfo{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Validate collects error strings in a slice and returns this
|
||||
func (info FederationInfo) Validate() []string {
|
||||
var result []string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue