21 lines
604 B
TypeScript
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();
|
|
}
|
|
} |