Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
NestJs: DTO que muestra todos los parámetros de consulta

Estoy tratando de usar 2 dto separados para parámetros de consulta en NestJs. Sin embargo, al imprimir, ambos dtos muestran las mismas propiedades. ¿Hay alguna forma de separarlos?

// codigo dto

 export class PageDto { @Type(() => Number) @IsInt() page: number; @Type(() => Number) @IsInt() limit: number; } export class MyDto { @ApiPropertyOptional() @IsString() @IsOptional() status: string; @ApiPropertyOptional() @IsString() @IsOptional() source: string; }

Solicitud de API:

OBTENER url?page=1&limit=10&status='active'&source='firebase'

controlador:

 @Get() async get( @Query() myDto: MyDto, @Query() pageDto: PageDto, ) { console.log({pageDto}, {myDto}); }

Se imprime la declaración de la consola:

 { pageDto: { page: 1, limit: 10, status: 'active', source: 'firebase' } } { myDto: { page: 1, limit: 10, status: 'active', source: 'firebase' } }

Requerido:

 { pageDto: { page: 1, limit: 10 } } { myDto: { status: 'active', source: 'firebase' } }

Idealmente, pageDto y myDto deberían mostrar sus respectivas propiedades.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Deberá configurar whitelist: true en sus opciones de ValidationPipe para decirle a class-transformer y class-validator que eliminen las propiedades que no existen en el DTO.

Referencia a los documentos

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!