types(feat) create location type

This commit is contained in:
Theo Technicguy 2023-06-21 22:59:55 +02:00
parent 2de5aa94d7
commit 8cd528f923
Signed by: theo.technicguy
GPG Key ID: 3BC661201BCA53D9
1 changed files with 29 additions and 0 deletions

29
types/location.go Normal file
View File

@ -0,0 +1,29 @@
/**
* 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()
}