defineInput
defineInput<
S>(schema):InputParser<{ [K in string | number | symbol]: S[K] extends InputField<V> ? V : never }>
Defined in: packages/actions/src/input-schema.ts:265
Builds a typed parser from a InputSchema. The returned function walks every field, collects errors, and either returns the typed object or throws InvalidInputError with all field errors at once.
Type Parameters
Section titled “Type Parameters”S extends InputSchema<unknown>
Parameters
Section titled “Parameters”schema
Section titled “schema”S
Returns
Section titled “Returns”InputParser<{ [K in string | number | symbol]: S[K] extends InputField<V> ? V : never }>
Example
Section titled “Example”import { createAction, defineInput, z } from "@cfast/actions";
const moveCard = createAction({ input: defineInput({ cardId: z.string(), position: z.integer(), // rejects NaN, fractional, missing pinned: z.optional(z.boolean()), }), handler: (db, input, ctx) => db.update(cards).set({ position: input.position }).where(eq(cards.id, input.cardId)),});