import { RacingDomainValidationError } from '../errors/RacingDomainError'; import type { IValueObject } from '@core/shared/domain'; export class JoinedAt implements IValueObject { private constructor(private readonly value: Date) {} static create(value: Date): JoinedAt { const now = new Date(); if (value > now) { throw new RacingDomainValidationError('Joined date cannot be in the future'); } return new JoinedAt(new Date(value)); } toDate(): Date { return new Date(this.value); } get props(): Date { return new Date(this.value); } equals(other: IValueObject): boolean { return this.props.getTime() === other.props.getTime(); } }