server/types/location.go

30 lines
525 B
Go

/**
* file: types/location.go
* author: Theo Technicguy
* license: Apache 2.0
*
* Location type and functions
*/
package types
type Location struct {
Id uint `json:"id"`
Name string `json:"name"`
Fridge bool `json:"fridge"`
Freezer bool `json:"freezer"`
Tags []Tag `json:"tags"`
}
func (l *Location) ValidKind() bool {
return !(l.Fridge && l.Freezer)
}
func (l *Location) ValidName() bool {
return l.Name != ""
}
func (l *Location) Valid() bool {
return l.ValidKind() && l.ValidName()
}