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