Files
gridpilot.gg/core/racing/domain/entities/LiveryTemplateUpdatedAt.ts
2025-12-17 00:33:13 +01:00

21 lines
604 B
TypeScript

import { RacingDomainValidationError } from '../errors/RacingDomainError';
export class LiveryTemplateUpdatedAt {
private constructor(private readonly value: Date) {}
static create(value: Date): LiveryTemplateUpdatedAt {
const now = new Date();
if (value > now) {
throw new RacingDomainValidationError('Updated date cannot be in the future');
}
return new LiveryTemplateUpdatedAt(new Date(value));
}
toDate(): Date {
return new Date(this.value);
}
equals(other: LiveryTemplateUpdatedAt): boolean {
return this.value.getTime() === other.value.getTime();
}
}