MCPcopy Create free account
hub / github.com/driangle/taskmd / checkInvalidFieldValues

Method checkInvalidFieldValues

sdk/go/validator/validator.go:154–210  ·  view source on GitHub ↗

checkInvalidFieldValues validates enum field values

(tasks []*model.Task, result *ValidationResult)

Source from the content-addressed store, hash-verified

152
153// checkInvalidFieldValues validates enum field values
154func (v *Validator) checkInvalidFieldValues(tasks []*model.Task, result *ValidationResult) {
155 validStatuses := map[model.Status]bool{
156 model.StatusPending: true,
157 model.StatusInProgress: true,
158 model.StatusCompleted: true,
159 model.StatusInReview: true,
160 model.StatusBlocked: true,
161 model.StatusCancelled: true,
162 "": true, // Empty is allowed (will default)
163 }
164
165 validPriorities := map[model.Priority]bool{
166 model.PriorityLow: true,
167 model.PriorityMedium: true,
168 model.PriorityHigh: true,
169 model.PriorityCritical: true,
170 "": true, // Empty is allowed (will default)
171 }
172
173 validEfforts := map[model.Effort]bool{
174 model.EffortSmall: true,
175 model.EffortMedium: true,
176 model.EffortLarge: true,
177 "": true, // Empty is allowed (will default)
178 }
179
180 validTypes := map[model.TaskType]bool{
181 model.TypeFeature: true,
182 model.TypeBug: true,
183 model.TypeImprovement: true,
184 model.TypeChore: true,
185 model.TypeDocs: true,
186 "": true, // Empty is allowed (optional field)
187 }
188
189 for _, task := range tasks {
190 if !validStatuses[task.Status] {
191 result.AddIssue(LevelError, task.ID, task.FilePath,
192 fmt.Sprintf("invalid status: '%s' (valid values: pending, in-progress, completed, in-review, blocked, cancelled)", task.Status))
193 }
194
195 if !validPriorities[task.Priority] {
196 result.AddIssue(LevelError, task.ID, task.FilePath,
197 fmt.Sprintf("invalid priority: '%s' (valid values: low, medium, high, critical)", task.Priority))
198 }
199
200 if !validEfforts[task.Effort] {
201 result.AddIssue(LevelError, task.ID, task.FilePath,
202 fmt.Sprintf("invalid effort: '%s' (valid values: small, medium, large)", task.Effort))
203 }
204
205 if !validTypes[task.Type] {
206 result.AddIssue(LevelWarning, task.ID, task.FilePath,
207 fmt.Sprintf("invalid type: '%s' (valid values: feature, bug, improvement, chore, docs)", task.Type))
208 }
209 }
210}
211

Callers 1

ValidateMethod · 0.95

Calls 1

AddIssueMethod · 0.80

Tested by

no test coverage detected