id must be a number conforming to the specified constraints

Viewed 7531

That's the error thrown by class-validator. Here is the code for my dto:

export class UpdateEntryBodyDto {
    @ApiProperty()
    @Type(() => Number)
    @IsNumber()
    id: number;

    @ApiProperty()
    @IsString()
    @IsOptional()
    @Validate(IsUniqueEntryTitle)
    title?: string;
}

I tried a few more different configurations but I'm getting about the same damn error. I'm totally discombobulated by this error, can't figure out what the hell is wrong with this code, I do it like it's recommended here but to no avail...

Can anyone help?

1 Answers

Ah, I've finally figured it out. I'm using Insomnia as my http client and I was sending Multipart Form (it used to be the case but no longer is) instead of Form Url Encoded. I simply forgot to change the request body type. So perhaps this will be of help if anyone stumbles across something like this.

Related