Validate party-game controller input
Validate unknown controller messages into an exhaustive discriminated union with finite, bounded numeric values.Description
Requirements
Export validateControllerInput from src/App.tsx.
Require a known button name and boolean pressed field with no missing values.
Require a known axis and finite value from minus one through one.
Require finite x and y values from zero through one.
Return a typed invalid result for null, arrays, unknown types, extra variant fields, or malformed values.
Return an observably equivalent result for equivalent inputs without reading time, randomness, network, storage, or DOM globals.
Do not mutate input objects, arrays, nested records, or values retained in the returned result.
Axis
{type:'axis', axis:'horizontal', value:-.5}Returns valid with the typed axis input
Require a known button name and boolean pressed field with no missing values.
Out of range
Pointer x is 1.2
Returns invalid with a range reason
Require a known axis and finite value from minus one through one.
Constraints
Implement a pure synchronous function with no external side effectsTreat every input collection and nested record as read-onlyReturn JSON-compatible data except where the declared TypeScript API explicitly uses bigint
Hints
Hint 1
Start with the validates-button behavior and make its observable result deterministic.
Hint 2
Model validates-axis independently before combining it with the remaining states.
Hint 3
Verify the boundary described by rejects-unknown-shape without changing caller-owned input.