/** * RaceScheduleCommandModel * * UX-only model for managing race creation/editing state. */ export interface RaceScheduleFormData { track: string; car: string; scheduledAtIso: string; } export interface RaceScheduleValidationErrors { track?: string; car?: string; scheduledAtIso?: string; } export class RaceScheduleCommandModel { private _track: string; private _car: string; private _scheduledAtIso: string; constructor(initial: Partial = {}) { this._track = initial.track || ''; this._car = initial.car || ''; this._scheduledAtIso = initial.scheduledAtIso || ''; } get track(): string { return this._track; } set track(value: string) { this._track = value; } get car(): string { return this._car; } set car(value: string) { this._car = value; } get scheduledAtIso(): string { return this._scheduledAtIso; } set scheduledAtIso(value: string) { this._scheduledAtIso = value; } validate(): RaceScheduleValidationErrors { const errors: RaceScheduleValidationErrors = {}; if (!this._track.trim()) errors.track = 'Track is required'; if (!this._car.trim()) errors.car = 'Car is required'; if (!this._scheduledAtIso) errors.scheduledAtIso = 'Date and time are required'; return errors; } toCommand(): { track: string; car: string; scheduledAtIso: string } { return { track: this._track, car: this._car, scheduledAtIso: this._scheduledAtIso, }; } }