# ParseArrayPipeOptions

**Kind:** Interface

**Source:** [`packages/common/pipes/parse-array.pipe.ts`](https://github.com/nestjs/nest/blob/master/packages/common/pipes/parse-array.pipe.ts#L19)

**Part of:** [Common](subsystem-packages-common)

`ParseArrayPipeOptions` configures how an array input is parsed and validated by `ParseArrayPipe`. It defines the expected item type, the delimiter used for string inputs, whether empty or missing values are allowed, and how parsing errors are converted into exceptions.

## Properties

| Property | Type |
|---|---|
| `items` | `Type<unknown>` |
| `separator` | `string` |
| `optional` | `boolean` |
| `exceptionFactory` | `(error: any) => any` |

## Diagram

```mermaid
graph LR
  Input[Request input] --> Pipe[ParseArrayPipe]
  Pipe --> Separator[separator: split string input]
  Separator --> Items[items: validate each item type]
  Pipe --> Optional[optional: allow missing value]
  Items --> Result[Parsed array]
  Pipe --> Errors[Validation error]
  Errors --> Factory[exceptionFactory]
  Factory --> Exception[Custom exception]
```

## Usage

```ts
import { ParseArrayPipe, ParseArrayPipeOptions } from '@nestjs/common';

const options: ParseArrayPipeOptions = {
  items: Number,
  separator: ',',
  optional: false,
  exceptionFactory: (error) => {
    throw new Error(`Invalid ID list: ${error}`);
  },
};

const parseIds = new ParseArrayPipe(options);

// "1,2,3" becomes [1, 2, 3]
const ids = await parseIds.transform('1,2,3', {
  type: 'query',
  data: 'ids',
  metatype: String,
});
```

## AI Coding Instructions

- Provide `items` when each array element should be validated or transformed as a specific runtime type.
- Use `separator` for comma-separated query parameters or other delimited string inputs; ensure it matches the API contract.
- Set `optional: true` only when omitted or empty input should pass through without raising a validation error.
- Use `exceptionFactory` to align parsing failures with the application's standard HTTP exception format.
- Keep custom exception factories deterministic and avoid exposing raw validation details to clients.
