Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal inconsistency #63

Open
rjnkr opened this issue Dec 25, 2024 · 0 comments
Open

Decimal inconsistency #63

rjnkr opened this issue Dec 25, 2024 · 0 comments

Comments

@rjnkr
Copy link

rjnkr commented Dec 25, 2024

Prisma model

model OperBrandstof {
@@Map("oper_brandstof")

/// @description Prijs per liter van de brandstof
PRIJS Decimal? @db.Decimal(6, 2)
}

The Create DTO looks like

@ApiProperty({
description: "Het bedrag van de tankbeurt om te kunnen factureren",
type: "number", <-- number
format: "double",
required: false,
nullable: true,
})
@IsOptional()
@IsDecimal()
PRIJS?: Prisma.Decimal | null;

The swagger example

{
"PRIJS": 0, <-- number
}

So far so good. It means that I have to provide numeric value for these fields. However when calling the api I need to provide these decimals as string. such as ""PRIJS": "2.01" to make it work. If is specify "PRIJS": 2.01, the error message "PRIJS is not a valid decimal number."

Also for the output the decimal is provided as string. So the interface implementation and the definition are inconsistent. I prefer to work with numbers instead of string. How can I solve this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant