Documentation
¶
Index ¶
- Constants
- func IsValid(task *Task) bool
- func NormalizePriority(priority string) int
- func PriorityLabel(priority int) string
- func StatusDisplay(status Status) string
- func StatusEmoji(status Status) string
- func StatusLabel(status Status) string
- func StatusToString(status Status) string
- func TypeDisplay(taskType Type) string
- func TypeEmoji(taskType Type) string
- func TypeLabel(taskType Type) string
- type Comment
- type ErrorCode
- type FieldValidator
- type PointsValidator
- type PriorityValidator
- type PriorityValue
- type SearchResult
- type Status
- type StatusValidator
- type TagsValue
- type Task
- type TaskValidator
- type TitleValidator
- type Type
- type TypeValidator
- type ValidationError
- type ValidationErrors
- type Validator
Constants ¶
const ( PriorityHigh = 1 PriorityMediumHigh = 2 PriorityMedium = 3 PriorityMediumLow = 4 PriorityLow = 5 )
Priority scale: lower = higher priority 1 = highest, 5 = lowest
const ( MinPriority = 1 MaxPriority = 5 DefaultPriority = 3 // Medium )
Priority validation constants
Variables ¶
This section is empty.
Functions ¶
func NormalizePriority ¶
NormalizePriority standardizes a raw priority string or number into an integer. Returns the normalized priority value (clamped to 1-5) or -1 if invalid.
func PriorityLabel ¶
PriorityLabel returns an emoji-based label for a priority value.
func StatusDisplay ¶
func StatusEmoji ¶
func StatusLabel ¶
func StatusToString ¶
StatusToString converts a Status to its string representation.
func TypeDisplay ¶
TypeDisplay returns a formatted display string with label and emoji.
Types ¶
type FieldValidator ¶
type FieldValidator interface {
ValidateField(task *Task) *ValidationError
}
FieldValidator validates a single field
type PointsValidator ¶
type PointsValidator struct{}
PointsValidator validates story points range (1-maxPoints from config)
func (*PointsValidator) ValidateField ¶
func (v *PointsValidator) ValidateField(task *Task) *ValidationError
type PriorityValidator ¶
type PriorityValidator struct{}
PriorityValidator validates priority range (1-5)
func (*PriorityValidator) ValidateField ¶
func (v *PriorityValidator) ValidateField(task *Task) *ValidationError
type PriorityValue ¶
type PriorityValue int
PriorityValue unmarshals priority from int or string (e.g., "high", "medium-high"). high=1, low=5. Values outside 1-5 range are clamped to boundaries.
func (PriorityValue) MarshalYAML ¶
func (p PriorityValue) MarshalYAML() (interface{}, error)
func (*PriorityValue) UnmarshalYAML ¶
func (p *PriorityValue) UnmarshalYAML(value *yaml.Node) error
type SearchResult ¶
SearchResult represents a task match with relevance score
type Status ¶
type Status string
func NormalizeStatus ¶
NormalizeStatus standardizes a raw status string into a Status.
func StatusColumn ¶
type StatusValidator ¶
type StatusValidator struct{}
StatusValidator validates task status enum
func (*StatusValidator) ValidateField ¶
func (v *StatusValidator) ValidateField(task *Task) *ValidationError
type TagsValue ¶
type TagsValue []string
TagsValue is a custom type for tags that provides lenient YAML unmarshaling. It gracefully handles invalid YAML by defaulting to an empty slice instead of failing.
func (TagsValue) MarshalYAML ¶
MarshalYAML implements YAML marshaling for TagsValue. Returns the underlying slice as-is for standard YAML serialization.
func (TagsValue) ToStringSlice ¶
ToStringSlice converts TagsValue to []string for use with Task entity.
func (*TagsValue) UnmarshalYAML ¶
UnmarshalYAML implements custom unmarshaling for tags with lenient error handling. Valid YAML list formats are parsed normally. Invalid formats (scalars, objects, etc.) default to empty slice with a warning log instead of returning an error.
type Task ¶
type Task struct {
ID string
Title string
Description string
Type Type
Status Status
Tags []string
Assignee string
Priority int // lower = higher priority
Points int
Comments []Comment
CreatedBy string // User who initially created the task
CreatedAt time.Time
UpdatedAt time.Time
LoadedMtime time.Time // File mtime when loaded (for optimistic locking)
}
Task represents a work item (user story, bug, etc.)
func (*Task) Validate ¶
func (t *Task) Validate() ValidationErrors
Validate validates the task using the standard validator
func (*Task) ValidateField ¶
func (t *Task) ValidateField(fieldName string) *ValidationError
ValidateField validates a single field
type TaskValidator ¶
type TaskValidator struct {
// contains filtered or unexported fields
}
TaskValidator orchestrates all field validators
func NewTaskValidator ¶
func NewTaskValidator() *TaskValidator
NewTaskValidator creates a validator with standard rules
func (*TaskValidator) Validate ¶
func (tv *TaskValidator) Validate(task *Task) ValidationErrors
Validate runs all validators and accumulates errors
func (*TaskValidator) ValidateField ¶
func (tv *TaskValidator) ValidateField(task *Task, fieldName string) *ValidationError
ValidateField validates a single field by name
type TitleValidator ¶
type TitleValidator struct{}
TitleValidator validates task title
func (*TitleValidator) ValidateField ¶
func (v *TitleValidator) ValidateField(task *Task) *ValidationError
type Type ¶
type Type string
Type represents the type of work item
func NormalizeType ¶
NormalizeType standardizes a raw type string into a Type.
type TypeValidator ¶
type TypeValidator struct{}
TypeValidator validates task type enum
func (*TypeValidator) ValidateField ¶
func (v *TypeValidator) ValidateField(task *Task) *ValidationError
type ValidationError ¶
type ValidationError struct {
Field string // Field name (e.g., "title", "priority")
Value any // The invalid value
Code ErrorCode // Machine-readable error code
Message string // Human-readable message
}
ValidationError represents a field-level validation failure with rich context
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []*ValidationError
ValidationErrors is a collection of field-level errors
func QuickValidate ¶
func QuickValidate(task *Task) ValidationErrors
QuickValidate is a convenience function for quick validation
func (ValidationErrors) ByField ¶
func (ve ValidationErrors) ByField(field string) []*ValidationError
ByField returns errors for a specific field
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string
func (ValidationErrors) HasErrors ¶
func (ve ValidationErrors) HasErrors() bool
HasErrors returns true if there are any validation errors
func (ValidationErrors) HasField ¶
func (ve ValidationErrors) HasField(field string) bool
HasField returns true if the field has any errors
type Validator ¶
type Validator interface {
Validate(task *Task) ValidationErrors
}
Validator is the main validation interface