UNPKG

1.18 kBTypeScriptView Raw
1import { ArgumentMetadata } from '../index';
2import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
3import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
4/**
5 * @publicApi
6 */
7export interface ParseEnumPipeOptions {
8 optional?: boolean;
9 errorHttpStatusCode?: ErrorHttpStatusCode;
10 exceptionFactory?: (error: string) => any;
11}
12/**
13 * Defines the built-in ParseEnum Pipe
14 *
15 * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
16 *
17 * @publicApi
18 */
19export declare class ParseEnumPipe<T = any> implements PipeTransform<T> {
20 protected readonly enumType: T;
21 protected readonly options?: ParseEnumPipeOptions;
22 protected exceptionFactory: (error: string) => any;
23 constructor(enumType: T, options?: ParseEnumPipeOptions);
24 /**
25 * Method that accesses and performs optional transformation on argument for
26 * in-flight requests.
27 *
28 * @param value currently processed route argument
29 * @param metadata contains metadata about the currently processed route argument
30 */
31 transform(value: T, metadata: ArgumentMetadata): Promise<T>;
32 protected isEnum(value: T): boolean;
33}