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