package storage import ( "gardomatic.kleiax.de/internal/platform/validate" "strings" "time" ) // CareInstructionModelInterface persists care instructions within their // species and garden boundary. type CareInstructionModelInterface interface { Insert(CareInstruction) (CareInstruction, error) Get(gardenID, speciesID, id int) (CareInstruction, error) GetAllForSpecies(gardenID, speciesID int) ([]CareInstruction, error) Update(gardenID int, instruction CareInstruction) (CareInstruction, error) Delete(gardenID, speciesID, id int) error } // CareInstruction records garden-specific cultivation knowledge for a species. type CareInstruction struct { ID int `json:"id"` SpeciesID int `json:"species_id"` Text string `json:"text"` Status string `json:"status"` CreatedBy int `json:"created_by"` UpdatedBy int `json:"updated_by"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Version int `json:"version"` } // ValidateCareInstruction applies the care-instruction input rules. func ValidateCareInstruction(v *validate.Validator, item CareInstruction) { v.Check(strings.TrimSpace(item.Text) != "", "text", "must be provided") v.Check(len(item.Text) <= 10000, "text", "must not be more than 10000 bytes long") v.Check(validate.PermittedValue(item.Status, "good", "bad", "untested", "testing", "planned"), "status", "is invalid") }