diff --git a/src/content/docs/en/reference/modules/astro-actions.mdx b/src/content/docs/en/reference/modules/astro-actions.mdx index c32ad91899e8a..796517fa5589a 100644 --- a/src/content/docs/en/reference/modules/astro-actions.mdx +++ b/src/content/docs/en/reference/modules/astro-actions.mdx @@ -575,3 +575,31 @@ type ContactResult = ActionReturnType; Represents the result of an action call: * on success, `data` contains the output of the action and `error` is `undefined`. * on failure, `error` contains an [`ActionError`](#actionerror) with validation errors or runtime errors, and `data` is `undefined`. + +### `ActionInputSchema` + +

+ +**Type:** `ZodType` + +

+ +A utility type that extracts the input's **zod schema type** from [an action handler](#defineaction). This can be useful if you need to reference an [action's validator](#input-validator) input type in your own type definitions. + +Even if the action [accepts `form`](#accept-property), `ActionInputSchema` lets you get the input type as `object` rather than [`FormData`](https://developer.mozilla.org/docs/Web/API/FormData). + +If the [`input` validator](#input-validator) is omitted, it returns `never`. + +The following example uses `ActionInputSchema` on an action named `contact` to: +* Retrieve the **zod schema type** for the input of the action. +* Retrieve the expected **input type** of the action's validator. + +```astro title="src/components/Form.astro" {4} +--- +import { actions, ActionInputSchema } from 'astro:actions'; +import { z } from 'astro/zod'; + +type ContactSchema = ActionInputSchema; +type ContactInput = z.input; +--- +```