diff --git a/src/content/docs/en/reference/modules/astro-actions.mdx b/src/content/docs/en/reference/modules/astro-actions.mdx index c32ad91899e8a..7d85ab5af3a03 100644 --- a/src/content/docs/en/reference/modules/astro-actions.mdx +++ b/src/content/docs/en/reference/modules/astro-actions.mdx @@ -443,6 +443,7 @@ import type { ActionAPIContext, ActionClient, ActionErrorCode, + ActionInputSchema, ActionReturnType, SafeResult, } from 'astro:actions'; @@ -546,6 +547,32 @@ button?.addEventListener('click', async () => { A union type of standard HTTP status codes [defined by IANA](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) using the human-readable versions as uppercase strings separated by an underscore (e.g. `BAD_REQUEST` or `PAYLOAD_TOO_LARGE`). +### `ActionInputSchema` + +

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

+ +A utility type that automatically infers the TypeScript type of an action's input based on its Zod schema. This can be useful to reference an action's [`input` validator type](#input-validator) as an object in your own type definitions. + +Returns `never` when [`input` validator](#input-validator) is omitted. + +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" {5} +--- +import { actions, ActionInputSchema } from 'astro:actions'; +import { z } from 'astro/zod'; + +type ContactSchema = ActionInputSchema; +type ContactInput = z.input; +--- +``` + ### `ActionReturnType`