pelican/internal/board/card.go
Dan Anglin 4e7eb77583
All checks were successful
/ test (pull_request) Successful in 40s
/ lint (pull_request) Successful in 43s
fix: add restrictions when setting IDs.
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.
2024-01-21 15:39:51 +00:00

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
}