UNPKG

2.81 kBTypeScriptView Raw
1import { ClassTransformOptions } from '../interfaces/external/class-transform-options.interface';
2import { TransformerPackage } from '../interfaces/external/transformer-package.interface';
3import { ValidationError } from '../interfaces/external/validation-error.interface';
4import { ValidatorOptions } from '../interfaces/external/validator-options.interface';
5import { ValidatorPackage } from '../interfaces/external/validator-package.interface';
6import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface';
7import { Type } from '../interfaces/type.interface';
8import { ErrorHttpStatusCode } from '../utils/http-error-by-code.util';
9/**
10 * @publicApi
11 */
12export interface ValidationPipeOptions extends ValidatorOptions {
13 transform?: boolean;
14 disableErrorMessages?: boolean;
15 transformOptions?: ClassTransformOptions;
16 errorHttpStatusCode?: ErrorHttpStatusCode;
17 exceptionFactory?: (errors: ValidationError[]) => any;
18 validateCustomDecorators?: boolean;
19 expectedType?: Type<any>;
20 validatorPackage?: ValidatorPackage;
21 transformerPackage?: TransformerPackage;
22}
23/**
24 * @see [Validation](https://docs.nestjs.com/techniques/validation)
25 *
26 * @publicApi
27 */
28export declare class ValidationPipe implements PipeTransform<any> {
29 protected isTransformEnabled: boolean;
30 protected isDetailedOutputDisabled?: boolean;
31 protected validatorOptions: ValidatorOptions;
32 protected transformOptions: ClassTransformOptions;
33 protected errorHttpStatusCode: ErrorHttpStatusCode;
34 protected expectedType: Type<any>;
35 protected exceptionFactory: (errors: ValidationError[]) => any;
36 protected validateCustomDecorators: boolean;
37 constructor(options?: ValidationPipeOptions);
38 protected loadValidator(validatorPackage?: ValidatorPackage): ValidatorPackage;
39 protected loadTransformer(transformerPackage?: TransformerPackage): TransformerPackage;
40 transform(value: any, metadata: ArgumentMetadata): Promise<any>;
41 createExceptionFactory(): (validationErrors?: ValidationError[]) => unknown;
42 protected toValidate(metadata: ArgumentMetadata): boolean;
43 protected transformPrimitive(value: any, metadata: ArgumentMetadata): any;
44 protected toEmptyIfNil<T = any, R = any>(value: T): R | {};
45 protected stripProtoKeys(value: any): void;
46 protected isPrimitive(value: unknown): boolean;
47 protected validate(object: object, validatorOptions?: ValidatorOptions): Promise<ValidationError[]> | ValidationError[];
48 protected flattenValidationErrors(validationErrors: ValidationError[]): string[];
49 protected mapChildrenToValidationErrors(error: ValidationError, parentPath?: string): ValidationError[];
50 protected prependConstraintsWithParentProp(parentPath: string, error: ValidationError): ValidationError;
51}