Skip to content

Does not work with ValidateIf and ValidateNested #62

@reeshabhranjan

Description

@reeshabhranjan

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:
image

I receive a 500 error because the audioUrls array was not properly validated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions