forked from dikhan/terraform-provider-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_types.go
54 lines (49 loc) · 1.63 KB
/
media_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
// Code generated by goagen v1.3.1, DO NOT EDIT.
//
// API "cellar": Application Media Types
//
// Command:
// $ goagen
// --design=github.com/dikhan/terraform-provider-openapi/examples/goa/api/design
// --out=$(GOPATH)/src/github.com/dikhan/terraform-provider-openapi/examples/goa/api
// --version=v1.3.1
package app
import (
"github.com/goadesign/goa"
"unicode/utf8"
)
// bottle media type (default view)
//
// Identifier: application/vnd.gophercon.goa.bottle; view=default
type Bottle struct {
// Unique bottle ID
ID string `form:"id" json:"id" yaml:"id" xml:"id"`
// Name of bottle
Name string `form:"name" json:"name" yaml:"name" xml:"name"`
// Rating of bottle
Rating int `form:"rating" json:"rating" yaml:"rating" xml:"rating"`
// Vintage of bottle
Vintage int `form:"vintage" json:"vintage" yaml:"vintage" xml:"vintage"`
}
// Validate validates the Bottle media type instance.
func (mt *Bottle) Validate() (err error) {
if mt.ID == "" {
err = goa.MergeErrors(err, goa.MissingAttributeError(`response`, "id"))
}
if mt.Name == "" {
err = goa.MergeErrors(err, goa.MissingAttributeError(`response`, "name"))
}
if utf8.RuneCountInString(mt.Name) < 1 {
err = goa.MergeErrors(err, goa.InvalidLengthError(`response.name`, mt.Name, utf8.RuneCountInString(mt.Name), 1, true))
}
if mt.Rating < 1 {
err = goa.MergeErrors(err, goa.InvalidRangeError(`response.rating`, mt.Rating, 1, true))
}
if mt.Rating > 5 {
err = goa.MergeErrors(err, goa.InvalidRangeError(`response.rating`, mt.Rating, 5, false))
}
if mt.Vintage < 1900 {
err = goa.MergeErrors(err, goa.InvalidRangeError(`response.vintage`, mt.Vintage, 1900, true))
}
return
}