0

Here is my code on nestjs

dto file

export class RequestDTO {
  @IsString()
  name: string;

  book: {
    authorone: string;
    authortwo: string;
  };

  @IsString()
  title: string = 'Test Book!';
}

On post request, I'm passing all params but I'm getting only

{
name: "test",
title: "Test Book!"
}

Why is book object data getting removed from this?

saravanan mp
  • 745
  • 3
  • 16
  • 34

1 Answers1

0

After updating to object dto

@IsOptional()
@IsObject({ each: true })
book: {
    authorone: string;
    authortwo: string;
};

its working fine

saravanan mp
  • 745
  • 3
  • 16
  • 34