import type { ValueObject } from '@core/shared/domain/ValueObject'; import { IdentityDomainValidationError } from '../errors/IdentityDomainError'; export interface RatingDeltaProps { value: number; } export class RatingDelta implements ValueObject { readonly value: number; private constructor(value: number) { this.value = value; } static create(value: number): RatingDelta { if (typeof value !== 'number' || isNaN(value)) { throw new IdentityDomainValidationError('Rating delta must be a valid number'); } if (value < -500 || value > 500) { throw new IdentityDomainValidationError( `Rating delta must be between -500 and 500, got: ${value}` ); } return new RatingDelta(value); } get props(): RatingDeltaProps { 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; } }