I have a problem I have a DTO that I created:
export class UpdateScoreDto {
@IsString()
readonly username: string;
@IsNotEmpty()
readonly score: number;
}
(I also tried adding @IsNumber())
But when using this DTO and accessing score to update my value in prisma I get:
Argument score: Invalid value provided. Expected Int or IntFieldUpdateOperationsInput, provided String.
(This is the code I run:
this.prisma.score.update({
where: { id: player.score.id },
data: {
score: updateScoreDto.score,
},
});
)
I can't cast it into an int because it is already an int and parseInt gives me an error (that it expects a string and I give a number).
BUT what did seems to work is:
score: parseInt(String(updateScoreDto.score))
So... even after declaring my score to be a number, it is treated as a string, but it is NOT a string, so I can't use parseInt on it, BUT, I can use String to convert the number into a string and then convert it back into a number!
Please help me, this doesn't make sense to me...