Skip to content

validateStartInput

validateStartInput(input, modalityOf): ValidateStartResult

Defined in: console-sdk/src/session/plan.ts:178

Dry-runs a StartWorkoutInput through the SAME resolution start() uses, returning the resolved plan or the rejection as a VALUE instead of throwing (SDK_PLAN.md §3.6.5). This is what a pre-flight “can I start?” UI needs: it can disable Start and show error.message without arming a workout — and without copying the SDK’s mode-coherence / role-coverage / leg-ceiling (MAX_EXPANDED_LEGS) rules, which would silently drift from firmware.

modalityOf resolves a bare-DeviceId input.devices to its modality (a fleet lookup the caller owns); it is never called for a RoleAssignment input. Pure apart from that callback: no clock, no I/O. It calls the exact resolveAssignment + resolvePlan the engine calls, so it can never diverge from what start() accepts.

StartWorkoutInput

The programming input to validate.

(id) => Modality | null

Resolves a device id to its modality (for the bare-id case).

ValidateStartResult

{ ok: true, plan }, or { ok: false, error } on any invalid-plan rejection.

const check = validateStartInput(input, (id) => deviceById(id)?.modality ?? null);
const canStart = check.ok;