20 lines
504 B
TypeScript
20 lines
504 B
TypeScript
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
|
|
|
export class DriverId {
|
|
private constructor(private readonly value: string) {}
|
|
|
|
static create(value: string): DriverId {
|
|
if (!value || value.trim().length === 0) {
|
|
throw new RacingDomainValidationError('Driver ID cannot be empty');
|
|
}
|
|
return new DriverId(value.trim());
|
|
}
|
|
|
|
toString(): string {
|
|
return this.value;
|
|
}
|
|
|
|
equals(other: DriverId): boolean {
|
|
return this.value === other.value;
|
|
}
|
|
} |