# CreateDecoratorOptions

**Kind:** Interface

**Source:** [`packages/core/services/reflector.service.ts`](https://github.com/nestjs/nest/blob/master/packages/core/services/reflector.service.ts#L8)

**Part of:** [Core](subsystem-packages-core)

`CreateDecoratorOptions` configures how a reflector decorator reads and transforms metadata values. It defines the metadata `key` to access and a `transform` function that converts the raw parameter value into the type consumed by the decorator or reflector service.

## Properties

| Property | Type |
|---|---|
| `key` | `string` |
| `transform` | `(value: TParam) => TTransformed` |

## Diagram

```mermaid
graph LR
  A[Decorator Invocation] --> B[CreateDecoratorOptions]
  B --> C[key: string]
  B --> D[transform(value)]
  C --> E[Reflector Metadata Lookup]
  E --> F[Raw Metadata Value]
  F --> D
  D --> G[Transformed Metadata Value]
```

## Usage

```ts
import type { CreateDecoratorOptions } from '@nestjs/core/services/reflector.service';

interface RoleOptions {
  roles: string[];
}

const roleDecoratorOptions: CreateDecoratorOptions<
  string[],
  RoleOptions
> = {
  key: 'roles',
  transform: (roles) => ({
    roles: roles.map((role) => role.toLowerCase()),
  }),
};

// The transform function receives the raw metadata value and returns
// the normalized value used by the application.
const normalizedRoles = roleDecoratorOptions.transform(['ADMIN', 'EDITOR']);

// { roles: ['admin', 'editor'] }
console.log(normalizedRoles);
```

## AI Coding Instructions

- Use a stable, unique `key` string that matches the metadata key used by the associated decorator.
- Keep `transform` pure: it should convert the input value without mutating it or relying on external state.
- Type `TParam` to match the raw decorator input and `TTransformed` to match the value consumers should receive.
- Validate or normalize optional, array, and nested values inside `transform` when downstream code expects a consistent shape.
- Ensure metadata readers use the same key and expect the transformed output type rather than the raw decorator argument.

## Relationships

- IMPORTS → `CustomDecorator`
- IMPORTS → `SetMetadata`
- IMPORTS → `Type`
- IMPORTS → `isEmpty`
- IMPORTS → `isObject`
