UNPKG

1.61 kBTypeScriptView Raw
1import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
2import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
3/**
4 * @publicApi
5 */
6export interface ParseBoolPipeOptions {
7 errorHttpStatusCode?: ErrorHttpStatusCode;
8 exceptionFactory?: (error: string) => any;
9 optional?: boolean;
10}
11/**
12 * Defines the built-in ParseBool Pipe
13 *
14 * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
15 *
16 * @publicApi
17 */
18export declare class ParseBoolPipe implements PipeTransform<string | boolean, Promise<boolean>> {
19 protected readonly options?: ParseBoolPipeOptions;
20 protected exceptionFactory: (error: string) => any;
21 constructor(options?: ParseBoolPipeOptions);
22 /**
23 * Method that accesses and performs optional transformation on argument for
24 * in-flight requests.
25 *
26 * @param value currently processed route argument
27 * @param metadata contains metadata about the currently processed route argument
28 */
29 transform(value: string | boolean, metadata: ArgumentMetadata): Promise<boolean>;
30 /**
31 * @param value currently processed route argument
32 * @returns `true` if `value` is said 'true', ie., if it is equal to the boolean
33 * `true` or the string `"true"`
34 */
35 protected isTrue(value: string | boolean): boolean;
36 /**
37 * @param value currently processed route argument
38 * @returns `true` if `value` is said 'false', ie., if it is equal to the boolean
39 * `false` or the string `"false"`
40 */
41 protected isFalse(value: string | boolean): boolean;
42}