# checkSpendControls

> Check a requirement against spend controls.

```ts
import { checkSpendControls } from 'x402-avm-js';
```

```ts
export function checkSpendControls(req: PaymentRequirements, controls: SpendControls = {}): void;
```

Check a requirement against spend controls. Throws before anything is built or signed.

## Parameters

- `req` (`PaymentRequirements`, required):

- `controls` (`SpendControls = {}`, required):

## Returns

- `returns` (`void`):

## Throws

- `SpendLimitExceededError`: If the amount is above the cap (default {@link DEFAULT_MAX_AMOUNT}).
- `PaymentNotAllowedError`: If the asset, network or recipient is not on an allow list.
- `InvalidOptionsError`: If a control is malformed.
- `InvalidPaymentRequiredError`: If the requirement's amount or asset is not an unsigned integer.

Source: [src/index.ts](https://github.com/x402-avm/x402-avm-js/blob/main/src/index.ts#L491)

Source: https://x402-avm.github.io/reference/js/check-spend-controls
