TaskValidator.Validators.IdValidator (TaskValidator v0.9.3)

View Source

Validates task IDs according to configured format rules.

This validator ensures that task IDs conform to the expected format, handles both main task and subtask ID patterns, and validates that subtask IDs properly reference their parent tasks.

Validation Rules

  1. Main Task IDs: Must match the configured ID regex pattern

    • Default pattern: [A-Z]{2,4}\d{3,4} (e.g., SSH001, VAL0004)
    • Custom patterns: Can include dashes (e.g., PROJ-001, CORE-123)
  2. Subtask IDs: Must follow parent-child relationship patterns

    • Numbered subtasks: PARENT-\d+ (e.g., SSH001-1, VAL0004-2)
    • Letter subtasks: PARENT[a-z] (e.g., SSH001a, VAL0004b)
  3. Prefix Consistency: All tasks in a task list should use consistent prefixes

    • Mixed prefixes are allowed but flagged as warnings
    • Helps identify potential organizational issues
  4. Duplicate Detection: Ensures no duplicate task IDs exist

Error Types

  • :invalid_id_format - ID doesn't match expected pattern
  • :duplicate_task_id - Multiple tasks with same ID
  • :invalid_subtask_id - Subtask ID doesn't reference valid parent
  • :mixed_prefixes - Multiple prefixes detected (warning only)

Examples

# Valid main task IDs
"SSH001", "VAL0004", "PROJ-001", "CORE-123"

# Valid subtask IDs
"SSH001-1", "VAL0004-2", "SSH001a", "VAL0004b"

# Invalid IDs
"ssh001"      # lowercase
"S001"        # too few letters
"SUPER001"    # too many letters
"SSH"         # missing numbers

Summary

Functions

Returns high priority (90) since ID validation is fundamental.

Validates task ID format, uniqueness, and subtask relationships.

Functions

priority()

Returns high priority (90) since ID validation is fundamental.

ID validation should run early as many other validators depend on valid task IDs for their logic.

validate(task, context)

Validates task ID format, uniqueness, and subtask relationships.

Context Requirements

  • :all_tasks - List of all tasks for duplicate and parent validation
  • :config - TaskValidator configuration (optional, uses defaults)

Returns

  • Success if all ID validations pass
  • Failure with specific error details for each validation issue