@nestjs/common
Version:
Decorators, pipes, exceptions and utilities for NestJS applications: @Controller(), @Injectable(), @Body(), ValidationPipe, HttpException and more.
67 lines (66 loc) • 2.53 kB
TypeScript
import { Type } from '../interfaces/index.js';
import { ArgumentMetadata, PipeTransform } from '../interfaces/features/pipe-transform.interface.js';
import { ValidationPipe, ValidationPipeOptions } from './validation.pipe.js';
/**
* @publicApi
*/
export interface ParseArrayPipeOptions extends Omit<ValidationPipeOptions, 'transform' | 'validateCustomDecorators' | 'exceptionFactory'> {
/**
* Type for items to be converted into
*/
items?: Type<unknown>;
/**
* Items separator to split string by
* @default ','
*/
separator?: string;
/**
* If true, the pipe will return null or undefined if the value is not provided
* @default false
*/
optional?: boolean;
/**
* Maximum total length, in characters, of the messages in an error response
* of the built-in exception factory. With `stopAtFirstError: false`, the
* messages of all the invalid items count together: once they reach it,
* the next invalid item ends the validation, the items after it are not
* validated, and a last message says that errors were left out. Set it to
* `Infinity` to lift the limit.
*
* @default 1_000_000
*/
maxErrorMessagesLength?: number;
/**
* A factory function that returns an exception object to be thrown
* if validation fails.
* @param error Error message or object
* @returns The exception object
*/
exceptionFactory?: (error: any) => any;
}
/** @deprecated Use `ParseArrayPipeOptions` instead. */
export type ParseArrayOptions = ParseArrayPipeOptions;
/**
* Defines the built-in ParseArray Pipe
*
* @see [Built-in Pipes](https://docs.nestjs.com/pipes#built-in-pipes)
*
* @publicApi
*/
export declare class ParseArrayPipe implements PipeTransform {
protected readonly options: ParseArrayPipeOptions;
protected readonly validationPipe: ValidationPipe;
protected exceptionFactory: (error: string) => any;
constructor(options?: ParseArrayPipeOptions);
/**
* Method that accesses and performs optional transformation on argument for
* in-flight requests.
*
* @param value currently processed route argument
* @param metadata contains metadata about the currently processed route argument
*/
transform(value: unknown, metadata: ArgumentMetadata): Promise<any>;
protected isExpectedTypePrimitive(): boolean;
protected validatePrimitive(originalValue: any, index?: number): any;
protected isNumeric(value: unknown): boolean;
}