A Zod schema representing the shape of the action input.
The payload returned on success.
The accumulated context passed through the pipeline.
A map where each key is an error code, and the corresponding value is the payload associated with that specific error.
Adds a validator function to the action pipeline.
The validator can extend the context and contribute to the combined error map.
A validation function to run before the action executes.
Same instance with extended context and error map.
Sets the final action function to execute after all validators succeed.
The action function receives the input params and the accumulated context.
The function to execute as the main action.
A bound execute function that runs the complete pipeline.
Executes the validation pipeline followed by the main action function.
If any validator fails, returns a structured error result. Otherwise, runs the action function and returns its result.
The input parameters to validate and pass to the action.
A promise resolving to an ActionResult.
Defines the Zod schema for the action's input.
This schema is not enforced automatically. To perform validation, use a
validator like zodValidator
.
The Zod schema to associate with the action.
Same instance with updated schema context.
A composable, type-safe action builder for creating a validation and execution pipeline.
This class enables step-by-step construction of an action by chaining validators and attaching a final action function. Each validator can inject some context or halt execution with an error. The final action executes only if all validators pass.