1

I have a setup like this:

export class RequestDTO {
  @ApiProperty()
  mainObj: MainObjDTO;
}

export class MainObjDTO {
  @ApiProperty()
  latLong: LatLongDTO
}

export class LatLongDTO {
  @ApiProperty()
  lat: string;

  @ApiProperty()
  long: string;  
}

When updating MainObj I have something like:

class PartialMainObjDTO extends PartialType(
  MainObjDTO,
) {}

export class UpdateRequestDTO {
  @ApiProperty()
  mainObj: PartialMainObjDTO;
}

The problem is that latLong is still marked as required during Update.

Is it possible to have a 'deep' PartialType somehow?

Dezzley
  • 1,463
  • 1
  • 13
  • 19
MB.
  • 4,167
  • 8
  • 52
  • 79
  • Is it that `latLong` is marked as required or is it that once you send ` latLog: { lat: somethign }` `latLong.long` is then required? – Jay McDoniel Sep 07 '22 at 14:40
  • I believe the default is that it's required. – MB. Oct 06 '22 at 23:58
  • Possible duplicate of [this question](https://stackoverflow.com/questions/67695710/nestjs-how-to-make-extend-partialtypecreatedto-make-nested-properties-of-dtos) – ns16 Aug 02 '23 at 07:37

1 Answers1

-2

Is your PartialType imported from @nestjs/swagger?

@Nestjs/swagger mapped-types

import { PartialType } from '@nestjs/swagger'
Cody Tseng
  • 190
  • 4