refactor
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
||||
import type { IValueObject } from '@core/shared/domain';
|
||||
|
||||
export class TeamCreatedAt {
|
||||
export class TeamCreatedAt implements IValueObject<Date> {
|
||||
private constructor(private readonly value: Date) {}
|
||||
|
||||
get props(): Date {
|
||||
return new Date(this.value);
|
||||
}
|
||||
|
||||
static create(value: Date): TeamCreatedAt {
|
||||
const now = new Date();
|
||||
if (value > now) {
|
||||
@@ -15,7 +20,7 @@ export class TeamCreatedAt {
|
||||
return new Date(this.value);
|
||||
}
|
||||
|
||||
equals(other: TeamCreatedAt): boolean {
|
||||
return this.value.getTime() === other.value.getTime();
|
||||
equals(other: IValueObject<Date>): boolean {
|
||||
return this.value.getTime() === other.props.getTime();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user