Files
gridpilot.gg/core/racing/domain/entities/CarName.ts
2025-12-17 00:33:13 +01:00

23 lines
621 B
TypeScript

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