23 lines
625 B
TypeScript
23 lines
625 B
TypeScript
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
|
|
|
export class GameName {
|
|
private constructor(private readonly value: string) {}
|
|
|
|
static create(value: string): GameName {
|
|
if (!value || value.trim().length === 0) {
|
|
throw new RacingDomainValidationError('Game name cannot be empty');
|
|
}
|
|
if (value.length > 50) {
|
|
throw new RacingDomainValidationError('Game name cannot exceed 50 characters');
|
|
}
|
|
return new GameName(value.trim());
|
|
}
|
|
|
|
toString(): string {
|
|
return this.value;
|
|
}
|
|
|
|
equals(other: GameName): boolean {
|
|
return this.value === other.value;
|
|
}
|
|
} |