nestjs-form-data
nestjs-form-data copied to clipboard
Does not work with `ValidateIf` and `ValidateNested`
This is the DTO (excerpt from it):
{
...
@IsArray()
@ArrayMinSize(1)
@ValidateIf((o) => o.type === AddHubElementTypes.AUDIO || o.type === AddHubElementTypes.GENERAL)
@ValidateNested({ each: true })
@Type(() => AudioUrlDto)
@ApiProperty()
@Transform(({ value }) => JSON.parse(value))
audioUrls?: AudioUrlDto[];
...
}
This is the definition of AudioUrlDto:
export class AudioUrlDto {
@IsEnum(HubPageAudioUrlType)
@ApiProperty()
type: HubPageAudioUrlType;
@IsUrl()
@ApiProperty()
url: string;
@IsInt()
@ApiProperty()
order: number;
}
This is what I send:
I receive a 500 error because the audioUrls array was not properly validated.