refactor
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { RacingDomainValidationError } from '../errors/RacingDomainError';
|
||||
import type { IValueObject } from '@core/shared/domain';
|
||||
|
||||
export class TrackLength {
|
||||
export class TrackLength implements IValueObject<number> {
|
||||
private constructor(private readonly value: number) {}
|
||||
|
||||
get props(): number {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
static create(value: number): TrackLength {
|
||||
if (value <= 0) {
|
||||
throw new RacingDomainValidationError('Track length must be positive');
|
||||
@@ -14,7 +19,7 @@ export class TrackLength {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
equals(other: TrackLength): boolean {
|
||||
return this.value === other.value;
|
||||
equals(other: IValueObject<number>): boolean {
|
||||
return this.value === other.props;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user