Documentation
¶
Overview ¶
Package validator checks task collections for structural and semantic errors.
It validates required fields, enum values, duplicate IDs, missing dependency references, circular dependencies, and parent-child relationships.
Index ¶
- type ConfigData
- type IDConfig
- type PhaseConfig
- type ScopeConfig
- type ValidationIssue
- type ValidationLevel
- type ValidationResult
- type Validator
- func (v *Validator) SetEffortScale(efforts effort.Scale)
- func (v *Validator) SetExternalIDs(ids map[string]bool)
- func (v *Validator) Validate(tasks []*model.Task) *ValidationResult
- func (v *Validator) ValidateConfig(config *ConfigData) *ValidationResult
- func (v *Validator) ValidatePhasesAgainstConfig(tasks []*model.Task, knownPhases map[string]bool) *ValidationResult
- func (v *Validator) ValidateTouchesAgainstScopes(tasks []*model.Task, knownScopes map[string]bool) *ValidationResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigData ¶
type ConfigData struct {
Scopes map[string]ScopeConfig
Phases []PhaseConfig
// StructuralErrors holds problems detected while parsing the raw config
// that can't be represented in the typed fields above — e.g. a section
// with the wrong YAML container type (a list where a map is expected).
// The CLI layer populates these; ValidateConfig surfaces them as errors.
StructuralErrors []string
TopKeys []string
ConfigPath string
Workflow string
ID *IDConfig
// Effort holds the configured effort vocabulary, lowest to highest.
// Nil means the key was absent and the default vocabulary applies.
Effort []string
}
ConfigData holds parsed config file data for validation. Extracted in the CLI layer so the validator stays viper-free.
type IDConfig ¶
type IDConfig struct {
Strategy string // "sequential", "prefixed", or "random"
Prefix string // required when strategy is "prefixed"
Length int // ID length (e.g. 6 for random IDs)
Padding int // zero-padding width for sequential IDs
}
IDConfig holds the configuration for task ID generation.
type PhaseConfig ¶
type PhaseConfig struct {
ID string
Name string
Description string
Due model.FlexibleTime
}
PhaseConfig holds the configuration for a single phase entry.
type ScopeConfig ¶
type ScopeConfig struct {
Description string // optional human-readable description
Paths []string // nil means the paths field was absent
}
ScopeConfig holds the configuration for a single scope entry.
type ValidationIssue ¶
type ValidationIssue struct {
Level ValidationLevel `json:"level"`
TaskID string `json:"task_id,omitempty"`
FilePath string `json:"file_path,omitempty"`
Message string `json:"message"`
}
ValidationIssue represents a single validation problem
type ValidationLevel ¶
type ValidationLevel string
ValidationLevel represents the severity of a validation issue
const ( LevelError ValidationLevel = "error" LevelWarning ValidationLevel = "warning" )
type ValidationResult ¶
type ValidationResult struct {
Issues []ValidationIssue `json:"issues"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
TaskCount int `json:"task_count"`
}
ValidationResult contains all validation issues found
func (*ValidationResult) AddIssue ¶
func (vr *ValidationResult) AddIssue(level ValidationLevel, taskID, filePath, message string)
AddIssue adds a validation issue and updates counters
func (*ValidationResult) HasWarnings ¶
func (vr *ValidationResult) HasWarnings() bool
HasWarnings returns true if there are warnings
func (*ValidationResult) IsValid ¶
func (vr *ValidationResult) IsValid() bool
IsValid returns true if there are no errors
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates task collections
func (*Validator) SetEffortScale ¶
SetEffortScale sets the project's effort vocabulary, used to validate the effort field. When unset, the default small, medium, large applies.
func (*Validator) SetExternalIDs ¶
SetExternalIDs sets task IDs that are known to exist externally (e.g. in archive). These IDs satisfy dependency and parent checks but are not validated themselves.
func (*Validator) Validate ¶
func (v *Validator) Validate(tasks []*model.Task) *ValidationResult
Validate performs all validation checks on a set of tasks
func (*Validator) ValidateConfig ¶
func (v *Validator) ValidateConfig(config *ConfigData) *ValidationResult
ValidateConfig checks the .taskmd.yaml config file for issues. Returns an empty result if config is nil.
func (*Validator) ValidatePhasesAgainstConfig ¶
func (v *Validator) ValidatePhasesAgainstConfig(tasks []*model.Task, knownPhases map[string]bool) *ValidationResult
ValidatePhasesAgainstConfig warns when tasks reference phases not defined in config. Skips validation if knownPhases is nil or empty.
func (*Validator) ValidateTouchesAgainstScopes ¶
func (v *Validator) ValidateTouchesAgainstScopes(tasks []*model.Task, knownScopes map[string]bool) *ValidationResult
ValidateTouchesAgainstScopes warns when tasks reference undefined scopes. Skips validation if knownScopes is nil or empty.