types(feat) create location type
This commit is contained in:
parent
2de5aa94d7
commit
8cd528f923
|
@ -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()
|
||||
}
|
Loading…
Reference in New Issue