package model import ( "fmt" ) type Post struct { ID int `json:"id"` UserID int `json:"user_id"` GameID int `json:"game_id"` CreatedAt int `json:"createdat"` Body string `json:"body"` } func (p *Post) IsValid() error { if p.UserID == 0 { return fmt.Errorf("user id must not be empty") } if p.GameID == 0 { return fmt.Errorf("game id must not be empty") } if p.CreatedAt == 0 { return fmt.Errorf("created at must not be empty") } if p.Body == "" { return fmt.Errorf("body must not be empty") } return nil }