Files
gridpilot.gg/core/racing/domain/value-objects/TrackId.ts
2025-12-27 19:18:54 +01:00

32 lines
627 B
TypeScript

import { z } from "zod";
const TrackIdSchema = z.string().uuid("TrackId must be a valid UUID");
export class TrackId {
private readonly _value: string;
private constructor(value: string) {
this._value = value;
}
static create(value: string): TrackId {
const validated = TrackIdSchema.parse(value);
return new TrackId(validated);
}
static fromString(value: string): TrackId {
return new TrackId(value);
}
get value(): string {
return this._value;
}
equals(other: TrackId): boolean {
return this._value === other._value;
}
toString(): string {
return this._value;
}
}