func (ctx *DeleteBottleContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
BadRequest sends a HTTP response with status code 400.
package app
import (
	"context"
	"github.com/goadesign/goa"
	"net/http"
	"strconv"
	"unicode/utf8"
)
type CreateAccountContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	Payload *CreateAccountPayload
}
func NewCreateAccountContext(ctx context.Context, r *http.Request, service *goa.Service) (*CreateAccountContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := CreateAccountContext{Context: ctx, ResponseData: resp, RequestData: req}
	return &rctx, err
}
type createAccountPayload struct {
	Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
}
func (payload *createAccountPayload) Validate() (err error) {
	if payload.Name == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	return
}
func (payload *createAccountPayload) Publicize() *CreateAccountPayload {
	var pub CreateAccountPayload
	if payload.Name != nil {
		pub.Name = *payload.Name
	}
	return &pub
}
type CreateAccountPayload struct {
	Name string `form:"name" json:"name" xml:"name"`
}
func (payload *CreateAccountPayload) Validate() (err error) {
	if payload.Name == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	return
}
func (ctx *CreateAccountContext) Created() error {
	ctx.ResponseData.WriteHeader(201)
	return nil
}
func (ctx *CreateAccountContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
type DeleteAccountContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	AccountID int
}
func NewDeleteAccountContext(ctx context.Context, r *http.Request, service *goa.Service) (*DeleteAccountContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := DeleteAccountContext{Context: ctx, ResponseData: resp, RequestData: req}
	paramAccountID := req.Params["accountID"]
	if len(paramAccountID) > 0 {
		rawAccountID := paramAccountID[0]
		if accountID, err2 := strconv.Atoi(rawAccountID); err2 == nil {
			rctx.AccountID = accountID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("accountID", rawAccountID, "integer"))
		}
	}
	return &rctx, err
}
func (ctx *DeleteAccountContext) NoContent() error {
	ctx.ResponseData.WriteHeader(204)
	return nil
}
func (ctx *DeleteAccountContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
func (ctx *DeleteAccountContext) NotFound() error {
	ctx.ResponseData.WriteHeader(404)
	return nil
}
type ListAccountContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
}
func NewListAccountContext(ctx context.Context, r *http.Request, service *goa.Service) (*ListAccountContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := ListAccountContext{Context: ctx, ResponseData: resp, RequestData: req}
	return &rctx, err
}
func (ctx *ListAccountContext) OK(r AccountCollection) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json; type=collection")
	}
	if r == nil {
		r = AccountCollection{}
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
func (ctx *ListAccountContext) OKLink(r AccountLinkCollection) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json; type=collection")
	}
	if r == nil {
		r = AccountLinkCollection{}
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
func (ctx *ListAccountContext) OKTiny(r AccountTinyCollection) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json; type=collection")
	}
	if r == nil {
		r = AccountTinyCollection{}
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
type ShowAccountContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	AccountID int
}
func NewShowAccountContext(ctx context.Context, r *http.Request, service *goa.Service) (*ShowAccountContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := ShowAccountContext{Context: ctx, ResponseData: resp, RequestData: req}
	paramAccountID := req.Params["accountID"]
	if len(paramAccountID) > 0 {
		rawAccountID := paramAccountID[0]
		if accountID, err2 := strconv.Atoi(rawAccountID); err2 == nil {
			rctx.AccountID = accountID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("accountID", rawAccountID, "integer"))
		}
		if rctx.AccountID < 1 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`accountID`, rctx.AccountID, 1, true))
		}
	}
	return &rctx, err
}
func (ctx *ShowAccountContext) OK(r *Account) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
func (ctx *ShowAccountContext) OKLink(r *AccountLink) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
func (ctx *ShowAccountContext) OKTiny(r *AccountTiny) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.account+json")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 200, r)
}
func (ctx *ShowAccountContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
func (ctx *ShowAccountContext) NotFound() error {
	ctx.ResponseData.WriteHeader(404)
	return nil
}
type UpdateAccountContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	AccountID int
	Payload   *UpdateAccountPayload
}
func NewUpdateAccountContext(ctx context.Context, r *http.Request, service *goa.Service) (*UpdateAccountContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := UpdateAccountContext{Context: ctx, ResponseData: resp, RequestData: req}
	paramAccountID := req.Params["accountID"]
	if len(paramAccountID) > 0 {
		rawAccountID := paramAccountID[0]
		if accountID, err2 := strconv.Atoi(rawAccountID); err2 == nil {
			rctx.AccountID = accountID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("accountID", rawAccountID, "integer"))
		}
	}
	return &rctx, err
}
type updateAccountPayload struct {
	Name *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
}
func (payload *updateAccountPayload) Validate() (err error) {
	if payload.Name == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	return
}
func (payload *updateAccountPayload) Publicize() *UpdateAccountPayload {
	var pub UpdateAccountPayload
	if payload.Name != nil {
		pub.Name = *payload.Name
	}
	return &pub
}
type UpdateAccountPayload struct {
	Name string `form:"name" json:"name" xml:"name"`
}
func (payload *UpdateAccountPayload) Validate() (err error) {
	if payload.Name == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	return
}
func (ctx *UpdateAccountContext) NoContent() error {
	ctx.ResponseData.WriteHeader(204)
	return nil
}
func (ctx *UpdateAccountContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
func (ctx *UpdateAccountContext) NotFound() error {
	ctx.ResponseData.WriteHeader(404)
	return nil
}
type CreateBottleContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	AccountID int
	Payload   *CreateBottlePayload
}
func NewCreateBottleContext(ctx context.Context, r *http.Request, service *goa.Service) (*CreateBottleContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := CreateBottleContext{Context: ctx, ResponseData: resp, RequestData: req}
	paramAccountID := req.Params["accountID"]
	if len(paramAccountID) > 0 {
		rawAccountID := paramAccountID[0]
		if accountID, err2 := strconv.Atoi(rawAccountID); err2 == nil {
			rctx.AccountID = accountID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("accountID", rawAccountID, "integer"))
		}
		if rctx.AccountID < 1 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`accountID`, rctx.AccountID, 1, true))
		}
	}
	return &rctx, err
}
type createBottlePayload struct {
	Color     *string `form:"color,omitempty" json:"color,omitempty" xml:"color,omitempty"`
	Country   *string `form:"country,omitempty" json:"country,omitempty" xml:"country,omitempty"`
	Name      *string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
	Region    *string `form:"region,omitempty" json:"region,omitempty" xml:"region,omitempty"`
	Review    *string `form:"review,omitempty" json:"review,omitempty" xml:"review,omitempty"`
	Sweetness *int    `form:"sweetness,omitempty" json:"sweetness,omitempty" xml:"sweetness,omitempty"`
	Varietal  *string `form:"varietal,omitempty" json:"varietal,omitempty" xml:"varietal,omitempty"`
	Vineyard  *string `form:"vineyard,omitempty" json:"vineyard,omitempty" xml:"vineyard,omitempty"`
	Vintage   *int    `form:"vintage,omitempty" json:"vintage,omitempty" xml:"vintage,omitempty"`
}
func (payload *createBottlePayload) Validate() (err error) {
	if payload.Name == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	if payload.Vineyard == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "vineyard"))
	}
	if payload.Varietal == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "varietal"))
	}
	if payload.Vintage == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "vintage"))
	}
	if payload.Color == nil {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "color"))
	}
	if payload.Color != nil {
		if !(*payload.Color == "red" || *payload.Color == "white" || *payload.Color == "rose" || *payload.Color == "yellow" || *payload.Color == "sparkling") {
			err = goa.MergeErrors(err, goa.InvalidEnumValueError(`raw.color`, *payload.Color, []interface{}{"red", "white", "rose", "yellow", "sparkling"}))
		}
	}
	if payload.Country != nil {
		if utf8.RuneCountInString(*payload.Country) < 2 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.country`, *payload.Country, utf8.RuneCountInString(*payload.Country), 2, true))
		}
	}
	if payload.Name != nil {
		if utf8.RuneCountInString(*payload.Name) < 2 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.name`, *payload.Name, utf8.RuneCountInString(*payload.Name), 2, true))
		}
	}
	if payload.Review != nil {
		if utf8.RuneCountInString(*payload.Review) < 3 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.review`, *payload.Review, utf8.RuneCountInString(*payload.Review), 3, true))
		}
	}
	if payload.Review != nil {
		if utf8.RuneCountInString(*payload.Review) > 300 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.review`, *payload.Review, utf8.RuneCountInString(*payload.Review), 300, false))
		}
	}
	if payload.Sweetness != nil {
		if *payload.Sweetness < 1 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.sweetness`, *payload.Sweetness, 1, true))
		}
	}
	if payload.Sweetness != nil {
		if *payload.Sweetness > 5 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.sweetness`, *payload.Sweetness, 5, false))
		}
	}
	if payload.Varietal != nil {
		if utf8.RuneCountInString(*payload.Varietal) < 4 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.varietal`, *payload.Varietal, utf8.RuneCountInString(*payload.Varietal), 4, true))
		}
	}
	if payload.Vineyard != nil {
		if utf8.RuneCountInString(*payload.Vineyard) < 2 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.vineyard`, *payload.Vineyard, utf8.RuneCountInString(*payload.Vineyard), 2, true))
		}
	}
	if payload.Vintage != nil {
		if *payload.Vintage < 1900 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.vintage`, *payload.Vintage, 1900, true))
		}
	}
	if payload.Vintage != nil {
		if *payload.Vintage > 2020 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.vintage`, *payload.Vintage, 2020, false))
		}
	}
	return
}
func (payload *createBottlePayload) Publicize() *CreateBottlePayload {
	var pub CreateBottlePayload
	if payload.Color != nil {
		pub.Color = *payload.Color
	}
	if payload.Country != nil {
		pub.Country = payload.Country
	}
	if payload.Name != nil {
		pub.Name = *payload.Name
	}
	if payload.Region != nil {
		pub.Region = payload.Region
	}
	if payload.Review != nil {
		pub.Review = payload.Review
	}
	if payload.Sweetness != nil {
		pub.Sweetness = payload.Sweetness
	}
	if payload.Varietal != nil {
		pub.Varietal = *payload.Varietal
	}
	if payload.Vineyard != nil {
		pub.Vineyard = *payload.Vineyard
	}
	if payload.Vintage != nil {
		pub.Vintage = *payload.Vintage
	}
	return &pub
}
type CreateBottlePayload struct {
	Color     string  `form:"color" json:"color" xml:"color"`
	Country   *string `form:"country,omitempty" json:"country,omitempty" xml:"country,omitempty"`
	Name      string  `form:"name" json:"name" xml:"name"`
	Region    *string `form:"region,omitempty" json:"region,omitempty" xml:"region,omitempty"`
	Review    *string `form:"review,omitempty" json:"review,omitempty" xml:"review,omitempty"`
	Sweetness *int    `form:"sweetness,omitempty" json:"sweetness,omitempty" xml:"sweetness,omitempty"`
	Varietal  string  `form:"varietal" json:"varietal" xml:"varietal"`
	Vineyard  string  `form:"vineyard" json:"vineyard" xml:"vineyard"`
	Vintage   int     `form:"vintage" json:"vintage" xml:"vintage"`
}
func (payload *CreateBottlePayload) Validate() (err error) {
	if payload.Name == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "name"))
	}
	if payload.Vineyard == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "vineyard"))
	}
	if payload.Varietal == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "varietal"))
	}
	if payload.Color == "" {
		err = goa.MergeErrors(err, goa.MissingAttributeError(`raw`, "color"))
	}
	if !(payload.Color == "red" || payload.Color == "white" || payload.Color == "rose" || payload.Color == "yellow" || payload.Color == "sparkling") {
		err = goa.MergeErrors(err, goa.InvalidEnumValueError(`raw.color`, payload.Color, []interface{}{"red", "white", "rose", "yellow", "sparkling"}))
	}
	if payload.Country != nil {
		if utf8.RuneCountInString(*payload.Country) < 2 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.country`, *payload.Country, utf8.RuneCountInString(*payload.Country), 2, true))
		}
	}
	if utf8.RuneCountInString(payload.Name) < 2 {
		err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.name`, payload.Name, utf8.RuneCountInString(payload.Name), 2, true))
	}
	if payload.Review != nil {
		if utf8.RuneCountInString(*payload.Review) < 3 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.review`, *payload.Review, utf8.RuneCountInString(*payload.Review), 3, true))
		}
	}
	if payload.Review != nil {
		if utf8.RuneCountInString(*payload.Review) > 300 {
			err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.review`, *payload.Review, utf8.RuneCountInString(*payload.Review), 300, false))
		}
	}
	if payload.Sweetness != nil {
		if *payload.Sweetness < 1 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.sweetness`, *payload.Sweetness, 1, true))
		}
	}
	if payload.Sweetness != nil {
		if *payload.Sweetness > 5 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.sweetness`, *payload.Sweetness, 5, false))
		}
	}
	if utf8.RuneCountInString(payload.Varietal) < 4 {
		err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.varietal`, payload.Varietal, utf8.RuneCountInString(payload.Varietal), 4, true))
	}
	if utf8.RuneCountInString(payload.Vineyard) < 2 {
		err = goa.MergeErrors(err, goa.InvalidLengthError(`raw.vineyard`, payload.Vineyard, utf8.RuneCountInString(payload.Vineyard), 2, true))
	}
	if payload.Vintage < 1900 {
		err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.vintage`, payload.Vintage, 1900, true))
	}
	if payload.Vintage > 2020 {
		err = goa.MergeErrors(err, goa.InvalidRangeError(`raw.vintage`, payload.Vintage, 2020, false))
	}
	return
}
func (ctx *CreateBottleContext) Created() error {
	ctx.ResponseData.WriteHeader(201)
	return nil
}
func (ctx *CreateBottleContext) BadRequest(r error) error {
	if ctx.ResponseData.Header().Get("Content-Type") == "" {
		ctx.ResponseData.Header().Set("Content-Type", "application/vnd.goa.error")
	}
	return ctx.ResponseData.Service.Send(ctx.Context, 400, r)
}
func (ctx *CreateBottleContext) NotFound() error {
	ctx.ResponseData.WriteHeader(404)
	return nil
}
type DeleteBottleContext struct {
	context.Context
	*goa.ResponseData
	*goa.RequestData
	AccountID int
	BottleID  int
}
func NewDeleteBottleContext(ctx context.Context, r *http.Request, service *goa.Service) (*DeleteBottleContext, error) {
	var err error
	resp := goa.ContextResponse(ctx)
	resp.Service = service
	req := goa.ContextRequest(ctx)
	req.Request = r
	rctx := DeleteBottleContext{Context: ctx, ResponseData: resp, RequestData: req}
	paramAccountID := req.Params["accountID"]
	if len(paramAccountID) > 0 {
		rawAccountID := paramAccountID[0]
		if accountID, err2 := strconv.Atoi(rawAccountID); err2 == nil {
			rctx.AccountID = accountID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("accountID", rawAccountID, "integer"))
		}
		if rctx.AccountID < 1 {
			err = goa.MergeErrors(err, goa.InvalidRangeError(`accountID`, rctx.AccountID, 1, true))
		}
	}
	paramBottleID := req.Params["bottleID"]
	if len(paramBottleID) > 0 {
		rawBottleID := paramBottleID[0]
		if bottleID, err2 := strconv.Atoi(rawBottleID); err2 == nil {
			rctx.BottleID = bottleID
		} else {
			err = goa.MergeErrors(err, goa.InvalidParamTypeError("bottleID", rawBottleID, "integer"))
		}
	}
	return &rctx, err
}
func (ctx *DeleteBottleContext) NoContent() error {
	ctx.ResponseData.WriteHeader(204)
	return nil
}