I want to combine multiple types at @Query() decorator (e.g. ParamsWithRegex and PaginationParams) , but when I do that no validation applied , how to fix that ?
**// MY CONTROLLER : here I combine two types but validate didnt work**
@Get()
async findAll(
@Query() query: PaginationParams & ParamsWithRegex,
) {
return 'OK'
}
// ParamsWithRegex.dto.ts
export class ParamsWithRegex {
@IsOptional()
@Transform(({ obj }) => {
return new RegExp(escapeRegExp(obj.name), 'i');
})
name?: string;
}
// paginationParams.dto.ts
export class PaginationParams {
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(1)
page?: number = 1;
@IsOptional()
@Type(() => Number)
@IsNumber()
@Min(1)
limit?: number = 8;
}