forked from goadesign/goa-cellar
/
user_types.go
88 lines (84 loc) · 2.94 KB
/
user_types.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
//************************************************************************//
// API "cellar": Application User Types
//
// Generated with goagen v0.0.1, command line:
// $ goagen.exe
// --out=$(GOPATH)\src\github.com\goadesign\goa-cellar
// --design=github.com/goadesign/goa-cellar/design
// --pkg=app
//
// The content of this file is auto-generated, DO NOT MODIFY
//************************************************************************//
package app
import "github.com/goadesign/goa"
// BottlePayload user type.
type BottlePayload struct {
Color *string `json:"color,omitempty" xml:"color,omitempty"`
Country *string `json:"country,omitempty" xml:"country,omitempty"`
Name *string `json:"name,omitempty" xml:"name,omitempty"`
Region *string `json:"region,omitempty" xml:"region,omitempty"`
Review *string `json:"review,omitempty" xml:"review,omitempty"`
Sweetness *int `json:"sweetness,omitempty" xml:"sweetness,omitempty"`
Varietal *string `json:"varietal,omitempty" xml:"varietal,omitempty"`
Vineyard *string `json:"vineyard,omitempty" xml:"vineyard,omitempty"`
Vintage *int `json:"vintage,omitempty" xml:"vintage,omitempty"`
}
// Validate validates the BottlePayload type instance.
func (ut *BottlePayload) Validate() (err error) {
if ut.Color != nil {
if !(*ut.Color == "red" || *ut.Color == "white" || *ut.Color == "rose" || *ut.Color == "yellow" || *ut.Color == "sparkling") {
err = goa.InvalidEnumValueError(`response.color`, *ut.Color, []interface{}{"red", "white", "rose", "yellow", "sparkling"})
}
}
if ut.Country != nil {
if len(*ut.Country) < 2 {
err = goa.InvalidLengthError(`response.country`, *ut.Country, len(*ut.Country), 2, true)
}
}
if ut.Name != nil {
if len(*ut.Name) < 2 {
err = goa.InvalidLengthError(`response.name`, *ut.Name, len(*ut.Name), 2, true)
}
}
if ut.Review != nil {
if len(*ut.Review) < 3 {
err = goa.InvalidLengthError(`response.review`, *ut.Review, len(*ut.Review), 3, true)
}
}
if ut.Review != nil {
if len(*ut.Review) > 300 {
err = goa.InvalidLengthError(`response.review`, *ut.Review, len(*ut.Review), 300, false)
}
}
if ut.Sweetness != nil {
if *ut.Sweetness < 1 {
err = goa.InvalidRangeError(`response.sweetness`, *ut.Sweetness, 1, true)
}
}
if ut.Sweetness != nil {
if *ut.Sweetness > 5 {
err = goa.InvalidRangeError(`response.sweetness`, *ut.Sweetness, 5, false)
}
}
if ut.Varietal != nil {
if len(*ut.Varietal) < 4 {
err = goa.InvalidLengthError(`response.varietal`, *ut.Varietal, len(*ut.Varietal), 4, true)
}
}
if ut.Vineyard != nil {
if len(*ut.Vineyard) < 2 {
err = goa.InvalidLengthError(`response.vineyard`, *ut.Vineyard, len(*ut.Vineyard), 2, true)
}
}
if ut.Vintage != nil {
if *ut.Vintage < 1900 {
err = goa.InvalidRangeError(`response.vintage`, *ut.Vintage, 1900, true)
}
}
if ut.Vintage != nil {
if *ut.Vintage > 2020 {
err = goa.InvalidRangeError(`response.vintage`, *ut.Vintage, 2020, false)
}
}
return
}