/
definition.go
49 lines (41 loc) · 1.05 KB
/
definition.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// NewServiceDefinition creates a new ServiceDefinition instance
func NewServiceDefinition(
name string,
description string,
tags []string,
author sdk.AccAddress,
authorDescription string,
schemas string,
) ServiceDefinition {
return ServiceDefinition{
Name: name,
Description: description,
Tags: tags,
Author: author.String(),
AuthorDescription: authorDescription,
Schemas: schemas,
}
}
// Validate validates the service definition
func (svcDef ServiceDefinition) Validate() error {
if err := ValidateAuthor(svcDef.Author); err != nil {
return err
}
if err := ValidateServiceName(svcDef.Name); err != nil {
return err
}
if err := ValidateTags(svcDef.Tags); err != nil {
return err
}
if err := ValidateServiceDescription(svcDef.Description); err != nil {
return err
}
if err := ValidateAuthorDescription(svcDef.AuthorDescription); err != nil {
return err
}
return ValidateServiceSchemas(svcDef.Schemas)
}