29 lines
763 B
TypeScript
29 lines
763 B
TypeScript
import type { ValueObject } from '@core/shared/domain/ValueObject';
|
|
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
|
|
|
|
export interface DriverBioProps {
|
|
value: string;
|
|
}
|
|
|
|
export class DriverBio implements ValueObject<DriverBioProps> {
|
|
private constructor(private readonly value: string) {}
|
|
|
|
static create(value: string): DriverBio {
|
|
if (value.length > 500) {
|
|
throw new RacingDomainValidationError('Driver bio cannot exceed 500 characters');
|
|
}
|
|
return new DriverBio(value);
|
|
}
|
|
|
|
toString(): string {
|
|
return this.value;
|
|
}
|
|
|
|
equals(other: ValueObject<DriverBioProps>): boolean {
|
|
return this.props.value === other.props.value;
|
|
}
|
|
|
|
get props(): DriverBioProps {
|
|
return { value: this.value };
|
|
}
|
|
} |