# validateOptions

**Kind:** Function

**Source:** [`src/middleware/language/language.ts`](https://github.com/honojs/hono/blob/main/src/middleware/language/language.ts#L204)

**Part of:** [Middleware](subsystem-src-middleware)

Validate detector options

`validateOptions` validates detector options before they are used by the language middleware. It checks that the supplied configuration matches the detector's expected option structure. Call it during middleware setup to reject invalid configuration early.

## Signature

```ts
function validateOptions(options: DetectorOptions): void
```

## Parameters

| Name | Type |
|---|---|
| `options` | `DetectorOptions` |

**Returns:** `void`

## Diagram

```mermaid
graph LR
  A[Detector options] --> B[validateOptions]
  B --> C[Valid options]
  B --> D[Invalid option error]
  C --> E[Language middleware]
```

## Usage

```ts
import { validateOptions } from './src/middleware/language/language';

const detectorOptions = {
  supportedLanguages: ['en', 'fr'],
  fallbackLanguage: 'en',
};

validateOptions(detectorOptions);

// Pass validated options to language middleware setup.
```

## AI Coding Instructions

- Validate detector configuration before creating or invoking the language middleware.
- Keep option names and value types aligned with the language detector configuration contract.
- Do not bypass validation when options come from environment variables or external configuration files.
- Update validation rules when adding detector options so invalid values fail at setup time.
