25 lines
678 B
TypeScript
25 lines
678 B
TypeScript
import type { ValueObject } from '@core/shared/domain/ValueObject';
|
|
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
|
|
|
export class TrackCountry implements ValueObject<string> {
|
|
private constructor(private readonly value: string) {}
|
|
|
|
get props(): string {
|
|
return this.value;
|
|
}
|
|
|
|
static create(value: string): TrackCountry {
|
|
if (!value || value.trim().length === 0) {
|
|
throw new RacingDomainValidationError('Track country is required');
|
|
}
|
|
return new TrackCountry(value.trim());
|
|
}
|
|
|
|
toString(): string {
|
|
return this.value;
|
|
}
|
|
|
|
equals(other: ValueObject<string>): boolean {
|
|
return this.value === other.props;
|
|
}
|
|
} |