---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/validation/functions/orderingGuardTurnMiddleware.md
---

# Function: orderingGuardTurnMiddleware()

```ts
function orderingGuardTurnMiddleware(
  options: OrderingGuardOptions,
): TurnPipelineMiddlewareFn;
```

Defined in: [src/batteries/validation/middleware.ts:427](https://github.com/NHTIO/ADK/blob/v1.20260824.1/src/src/batteries/validation/middleware.ts#L427)

Builds a [@nhtio/adk!TurnPipelineMiddlewareFn](../../../turn_runner/type-aliases/TurnPipelineMiddlewareFn.md) running the same ordering-guard core as
[orderingGuardDispatchMiddleware](orderingGuardDispatchMiddleware.md), once per turn before the first executor call.

## Parameters

| Parameter | Type                                                                  | Description                                                                                         |
| --------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `options` | [`OrderingGuardOptions`](../types/interfaces/OrderingGuardOptions.md) | Same shape and validation as [orderingGuardDispatchMiddleware](orderingGuardDispatchMiddleware.md). |

## Returns

[`TurnPipelineMiddlewareFn`](../../../turn_runner/type-aliases/TurnPipelineMiddlewareFn.md)

A turn-pipeline middleware function with the same enforce/mutate semantics.

## Remarks

`TurnContext` has no `nack()` — only `abort()` — so the default `onViolation: 'nack'`
behavior maps to `ctx.abort(error)` here rather than a dispatch-style nack; `onViolation:
'throw'` still throws in both middleware. This asymmetry is a real, documented difference
between the two contexts, not an inconsistency.
