import type { ValueObject } from '@core/shared/domain/ValueObject'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; export interface TeamRatingDeltaProps { value: number; } export class TeamRatingDelta implements ValueObject { readonly value: number; private constructor(value: number) { this.value = value; } static create(value: number): TeamRatingDelta { if (typeof value !== 'number' || isNaN(value)) { throw new RacingDomainValidationError('Team rating delta must be a valid number'); } // Delta can be negative or positive, but within reasonable bounds if (value < -100 || value > 100) { throw new RacingDomainValidationError( `Team rating delta must be between -100 and 100, got: ${value}` ); } return new TeamRatingDelta(value); } get props(): TeamRatingDeltaProps { return { value: this.value }; } equals(other: ValueObject): boolean { return this.value === other.props.value; } toNumber(): number { return this.value; } toString(): string { return this.value.toString(); } isPositive(): boolean { return this.value > 0; } isNegative(): boolean { return this.value < 0; } isZero(): boolean { return this.value === 0; } }