Skip to main content

validate_task_id

Function validate_task_id 

Source
pub fn validate_task_id(id: &str) -> Result<(), NikaError>
Expand description

Validate a task ID without regex overhead

Manual implementation for optimal performance:

  • O(n) single-pass validation
  • Zero allocations
  • No regex compilation overhead

Valid task IDs:

  • Start with lowercase letter [a-z]
  • Contain only lowercase letters, digits, underscores [a-z0-9_]*

Invalid patterns:

  • Dashes: fetch-api (use fetch_api)
  • Uppercase: myTask (use my_task)
  • Dots: weather.api (dots reserved for paths)
  • Numbers first: 123task (must start with letter)
  • Leading underscore: _private (not idiomatic)