...
1
9
10 package openapi
11
12 type Resource struct {
13 Name string `json:"name"`
14
15 Inlined string `json:"inlined,omitempty"`
16
17 Uri string `json:"uri,omitempty"`
18
19 DeployByDefault string `json:"deployByDefault"`
20
21
22 Orphan bool `json:"orphan"`
23 }
24
25
26 func AssertResourceRequired(obj Resource) error {
27 elements := map[string]interface{}{
28 "name": obj.Name,
29 "deployByDefault": obj.DeployByDefault,
30 "orphan": obj.Orphan,
31 }
32 for name, el := range elements {
33 if isZero := IsZeroValue(el); isZero {
34 return &RequiredError{Field: name}
35 }
36 }
37
38 return nil
39 }
40
41
42
43 func AssertRecurseResourceRequired(objSlice interface{}) error {
44 return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
45 aResource, ok := obj.(Resource)
46 if !ok {
47 return ErrTypeAssertionError
48 }
49 return AssertResourceRequired(aResource)
50 })
51 }
52
View as plain text