Dan Anglin
4e7eb77583
Main change: Add restrictions when adding IDs for cards and statuses. Errors are returned when an attempt is made to set an ID lower than 1, or an attempt is made to set an ID that has already been set. Additional changes: - Error types in the board packages are now defined in errors.go. - Small formatting to error messages.
30 lines
484 B
Go
30 lines
484 B
Go
package board
|
|
|
|
// Card represents a card on a Kanban board.
|
|
type Card struct {
|
|
ID int
|
|
Title string
|
|
Description string
|
|
Created string
|
|
}
|
|
|
|
// SetID updates the ID of the Card value only if
|
|
// the ID is < 1 (i.e. unset).
|
|
func (c *Card) SetID(id int) error {
|
|
if id < 1 {
|
|
return InvalidIDError{id}
|
|
}
|
|
|
|
if c.ID > 0 {
|
|
return IDAlreadySetError{}
|
|
}
|
|
|
|
c.ID = id
|
|
|
|
return nil
|
|
}
|
|
|
|
// GetID returns the ID of the Card value.
|
|
func (c *Card) GetID() int {
|
|
return c.ID
|
|
}
|