This commit is contained in:
2025-12-17 00:33:13 +01:00
parent 8c67081953
commit f01e01e50c
186 changed files with 9242 additions and 1342 deletions

View File

@@ -1,27 +1,23 @@
import { RacingDomainValidationError } from '../errors/RacingDomainError';
import type { IEntity } from '@core/shared/domain';
export class Game implements IEntity<string> {
readonly id: string;
readonly name: string;
import { GameId } from './GameId';
import { GameName } from './GameName';
private constructor(props: { id: string; name: string }) {
export class Game implements IEntity<GameId> {
readonly id: GameId;
readonly name: GameName;
private constructor(props: { id: GameId; name: GameName }) {
this.id = props.id;
this.name = props.name;
}
static create(props: { id: string; name: string }): Game {
if (!props.id || props.id.trim().length === 0) {
throw new RacingDomainValidationError('Game ID is required');
}
if (!props.name || props.name.trim().length === 0) {
throw new RacingDomainValidationError('Game name is required');
}
const id = GameId.create(props.id);
const name = GameName.create(props.name);
return new Game({
id: props.id,
name: props.name,
id,
name,
});
}
}