UNPKG

1.54 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 ParseUUIDPipeOptions {
7 /**
8 * UUID version to validate
9 */
10 version?: '3' | '4' | '5' | '7';
11 /**
12 * The HTTP status code to be used in the response when the validation fails.
13 */
14 errorHttpStatusCode?: ErrorHttpStatusCode;
15 /**
16 * A factory function that returns an exception object to be thrown
17 * if validation fails.
18 * @param error Error message
19 * @returns The exception object
20 */
21 exceptionFactory?: (errors: string) => any;
22 /**
23 * If true, the pipe will return null or undefined if the value is not provided
24 * @default false
25 */
26 optional?: boolean;
27}
28/**
29 * Defines the built-in ParseUUID Pipe
30 *
31 * @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
32 *
33 * @publicApi
34 */
35export declare class ParseUUIDPipe implements PipeTransform<string> {
36 protected readonly options?: ParseUUIDPipeOptions | undefined;
37 protected static uuidRegExps: {
38 3: RegExp;
39 4: RegExp;
40 5: RegExp;
41 7: RegExp;
42 all: RegExp;
43 };
44 private readonly version;
45 protected exceptionFactory: (errors: string) => any;
46 constructor(options?: ParseUUIDPipeOptions | undefined);
47 transform(value: string, metadata: ArgumentMetadata): Promise<string>;
48 protected isUUID(str: unknown, version?: string): any;
49}