import type { IValueObject } from '@core/shared/domain'; import { IdentityDomainValidationError } from '../errors/IdentityDomainError'; export interface RatingDeltaProps { value: number; } export class RatingDelta implements IValueObject { 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 < -100 || value > 100) { throw new IdentityDomainValidationError( `Rating delta must be between -100 and 100, got: ${value}` ); } return new RatingDelta(value); } get props(): RatingDeltaProps { return { value: this.value }; } equals(other: IValueObject): 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; } }