TaskValidator (TaskValidator v0.5.0)

View Source

Validates TaskList.md format compliance according to project guidelines.

The TaskValidator ensures that task documents follow a consistent structure, making it easier to track and manage work across multiple project components, with a strong focus on error handling practices.

Validation Checks

  • ID format compliance (like SSH0001, SCP0001, ERR001, etc.)
  • Unique task IDs across the document
  • Required sections and fields present in each task, including Error Handling Guidelines
  • Different error handling requirements for main tasks and subtasks:
    • Main tasks: Comprehensive error handling documentation with GenServer-specific examples
    • Subtasks: Simplified error handling focused on task-specific approaches
  • Proper subtask structure with consistent prefixes
  • Valid status values from the allowed list
  • Proper review rating format for completed tasks
  • Error handling patterns and conventions

Error Handling Requirements

Main tasks must include comprehensive error handling sections:

**Error Handling**
**Core Principles**
- Pass raw errors
- Use {:ok, result} | {:error, reason}
- Let it crash
**Error Implementation**
- No wrapping
- Minimal rescue
- function/1 & /! versions
**Error Examples**
- Raw error passthrough
- Simple rescue case
- Supervisor handling
**GenServer Specifics**
- Handle_call/3 error pattern
- Terminate/2 proper usage
- Process linking considerations

Subtasks have a simplified error handling format:

**Error Handling**
**Task-Specific Approach**
- Error pattern for this task
**Error Reporting**
- Monitoring approach

Usage Example

case TaskValidator.validate_file("path/to/TaskList.md") do
  {:ok, message} ->
    # Task list validation succeeded
    IO.puts("Validation passed: " <> message)
  {:error, reason} ->
    # Task list validation failed
    IO.puts("Validation failed: " <> reason)
end

Summary

Functions

Extracts tasks from the TaskList.md content.

Validates a TaskList.md file against the specified format requirements.

Functions

extract_tasks(lines)

@spec extract_tasks([String.t()]) :: {:ok, [map()]} | {:error, String.t()}

Extracts tasks from the TaskList.md content.

validate_file(file_path)

@spec validate_file(String.t()) :: :ok | {:error, String.t()}

Validates a TaskList.md file against the specified format requirements.

Returns :ok if validation passes, or {:error, reason} if it fails.