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

# Function: asyncValidateOrThrow()

```ts
function asyncValidateOrThrow<T>(
  schema: Schema,
  value: unknown,
  convert?: boolean,
): Promise<T>;
```

Defined in: [src/lib/utils/validation.ts:136](https://github.com/NHTIO/ADK/blob/v1.20260824.1/src/src/lib/utils/validation.ts#L136)

Validates `value` against `schema` asynchronously and returns the coerced result typed as `T`.

## Type Parameters

| Type Parameter | Description                                                  |
| -------------- | ------------------------------------------------------------ |
| `T`            | The expected type of the validated and coerced return value. |

## Parameters

| Parameter | Type      | Default value | Description                                                                                                                                            |
| --------- | --------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `schema`  | `Schema`  | `undefined`   | The schema to validate against.                                                                                                                        |
| `value`   | `unknown` | `undefined`   | The value to validate.                                                                                                                                 |
| `convert` | `boolean` | `false`       | When `true`, the validator coerces values to their target types (e.g. string `"1"` → number `1`). Defaults to `false` to prevent silent type coercion. |

## Returns

`Promise`<`T`>

The validated (and optionally coerced) value typed as `T`.

## Remarks

Collects all field errors before throwing. Prefer this over [validateOrThrow](validateOrThrow.md) when the
schema includes async custom validators.

## Throws

ValidationException when `value` does not satisfy `schema`.
