1.39 kBTypeScriptView Raw
1import { PipeTransform } from '../interfaces/features/pipe-transform.interface';
2import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
3export interface ParseDatePipeOptions {
4 /**
5 * If true, the pipe will return null or undefined if the value is not provided
6 * @default false
7 */
8 optional?: boolean;
9 /**
10 * Default value for the date
11 */
12 default?: () => Date;
13 /**
14 * The HTTP status code to be used in the response when the validation fails.
15 */
16 errorHttpStatusCode?: ErrorHttpStatusCode;
17 /**
18 * A factory function that returns an exception object to be thrown
19 * if validation fails.
20 * @param error Error message
21 * @returns The exception object
22 */
23 exceptionFactory?: (error: string) => any;
24}
25export declare class ParseDatePipe implements PipeTransform<string | number | undefined | null> {
26 private readonly options;
27 protected exceptionFactory: (error: string) => any;
28 constructor(options?: ParseDatePipeOptions);
29 /**
30 * Method that accesses and performs optional transformation on argument for
31 * in-flight requests.
32 *
33 * @param value currently processed route argument
34 * @param metadata contains metadata about the currently processed route argument
35 */
36 transform(value: string | number | undefined | null): Date | null | undefined;
37}