import type { ValueObject } from '@core/shared/domain/ValueObject'; import { RacingDomainValidationError } from '../errors/RacingDomainError'; export class JoinedAt implements ValueObject { 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: ValueObject): boolean { return this.props.getTime() === other.props.getTime(); } }