-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathview.go
132 lines (119 loc) · 3.26 KB
/
view.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Code generated by goa v3.15.2, DO NOT EDIT.
//
// tools views
//
// Command:
// $ goa gen github.com/arduino/arduino-create-agent/design
package views
import (
goa "goa.design/goa/v3/pkg"
)
// ToolCollection is the viewed result type that is projected based on a view.
type ToolCollection struct {
// Type to project
Projected ToolCollectionView
// View to render
View string
}
// Operation is the viewed result type that is projected based on a view.
type Operation struct {
// Type to project
Projected *OperationView
// View to render
View string
}
// ToolCollectionView is a type that runs validations on a projected type.
type ToolCollectionView []*ToolView
// ToolView is a type that runs validations on a projected type.
type ToolView struct {
// The name of the tool
Name *string
// The version of the tool
Version *string
// The packager of the tool
Packager *string
}
// OperationView is a type that runs validations on a projected type.
type OperationView struct {
// The status of the operation
Status *string
}
var (
// ToolCollectionMap is a map indexing the attribute names of ToolCollection by
// view name.
ToolCollectionMap = map[string][]string{
"default": {
"name",
"version",
"packager",
},
}
// OperationMap is a map indexing the attribute names of Operation by view name.
OperationMap = map[string][]string{
"default": {
"status",
},
}
// ToolMap is a map indexing the attribute names of Tool by view name.
ToolMap = map[string][]string{
"default": {
"name",
"version",
"packager",
},
}
)
// ValidateToolCollection runs the validations defined on the viewed result
// type ToolCollection.
func ValidateToolCollection(result ToolCollection) (err error) {
switch result.View {
case "default", "":
err = ValidateToolCollectionView(result.Projected)
default:
err = goa.InvalidEnumValueError("view", result.View, []any{"default"})
}
return
}
// ValidateOperation runs the validations defined on the viewed result type
// Operation.
func ValidateOperation(result *Operation) (err error) {
switch result.View {
case "default", "":
err = ValidateOperationView(result.Projected)
default:
err = goa.InvalidEnumValueError("view", result.View, []any{"default"})
}
return
}
// ValidateToolCollectionView runs the validations defined on
// ToolCollectionView using the "default" view.
func ValidateToolCollectionView(result ToolCollectionView) (err error) {
for _, item := range result {
if err2 := ValidateToolView(item); err2 != nil {
err = goa.MergeErrors(err, err2)
}
}
return
}
// ValidateToolView runs the validations defined on ToolView using the
// "default" view.
func ValidateToolView(result *ToolView) (err error) {
if result.Name == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("name", "result"))
}
if result.Version == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("version", "result"))
}
if result.Packager == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("packager", "result"))
}
return
}
// ValidateOperationView runs the validations defined on OperationView using
// the "default" view.
func ValidateOperationView(result *OperationView) (err error) {
if result.Status == nil {
err = goa.MergeErrors(err, goa.MissingFieldError("status", "result"))
}
return
}