All files / domain/valueObjects TaskTitle.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  5x   58x 58x   58x 3x     55x 2x     53x       58x       20x      
export class TaskTitle {
  private static readonly MAX_LENGTH = 200;
  
  private constructor(private readonly value: string) {
    const trimmed = value.trim();
    
    if (trimmed.length === 0) {
      throw new Error('Task title cannot be empty');
    }
    
    if (trimmed.length > TaskTitle.MAX_LENGTH) {
      throw new Error(`Task title cannot exceed ${TaskTitle.MAX_LENGTH} characters`);
    }
    
    this.value = trimmed;
  }
 
  static create(value: string): TaskTitle {
    return new TaskTitle(value);
  }
 
  toString(): string {
    return this.value;
  }
}