# ParseDatePipeOptions

**Kind:** Interface

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

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

`ParseDatePipeOptions` configures how a date-parsing pipe handles incoming values and validation failures. It controls whether values may be omitted, supplies a fallback date, and defines how parsing errors are converted into HTTP exceptions.

## Properties

| Property | Type |
|---|---|
| `optional` | `boolean` |
| `default` | `() => Date` |
| `errorHttpStatusCode` | `ErrorHttpStatusCode` |
| `exceptionFactory` | `(error: string) => any` |

## Diagram

```mermaid
graph LR
  Input[Incoming date value] --> Pipe[ParseDatePipe]
  Pipe --> Optional{optional?}
  Optional -- Missing and allowed --> Default[default(): Date]
  Optional -- Value provided --> Parse[Parse and validate date]
  Parse -- Valid --> Date[Date result]
  Parse -- Invalid --> Factory[exceptionFactory(error)]
  Factory --> Error[HTTP exception]
  Status[errorHttpStatusCode] --> Factory
```

## Usage

```ts
import { ParseDatePipeOptions } from '@nestjs/common';

const datePipeOptions: ParseDatePipeOptions = {
  optional: true,
  default: () => new Date(),
  errorHttpStatusCode: 400,
  exceptionFactory: (error: string) => ({
    statusCode: 400,
    message: `Invalid date: ${error}`,
  }),
};

// Example: pass these options when configuring the date parsing pipe.
```

## AI Coding Instructions

- Set `optional: true` only when an absent input should be accepted; provide a `default` callback for the resulting value.
- Keep `default` as a function so a fresh `Date` instance is created for every pipe invocation.
- Use `errorHttpStatusCode` consistently with the API's validation-error conventions.
- Ensure `exceptionFactory` returns an exception shape recognized by the surrounding HTTP framework.
- Include actionable parsing details in the `error` message without exposing sensitive request data.
