omar-dulaimi / prisma-class-validator-generator

Prisma 2+ generator to emit typescript models of your database with class validator
MIT License
65 stars 11 forks source link

Add support for Float #1

Closed jackall3n closed 1 year ago

jackall3n commented 2 years ago

Description

Adding support for the type Float. Given class-validator doesn't have out-of-the-box support for floats, I've made it fallback to the configuration of Ints.

omar-dulaimi commented 2 years ago

Hello @jackall3n , thank you for the contribution.

I agree that we need to support other types like Float, but we shouldn't use @IsInt() with it.

Unless you could build a custom validator, I think the safe thing to do is to remove @IsInt() for now.

Please check review details, I left you some feedback.

erlanggadewa commented 1 year ago

@jackall3n you can try to use Decimal instead of Float, and it's work fine witdh Decimal or you can check the docs https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#decimal

jackall3n commented 1 year ago

@jackall3n you can try to use Decimal instead of Float, and it's work fine witdh Decimal or you can check the docs https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#decimal

Thanks @ErlanggaDewa, it's a good option I could explore for new databases, however, my one exists already and I'm not sure changing the datatype to support this library is going to be worth it.

omar-dulaimi commented 1 year ago

Thanks guys. I'm merging this now. Feel free to suggest changes or improvements anytime.

omar-dulaimi commented 1 year ago

Release in https://github.com/omar-dulaimi/prisma-class-validator-generator/releases/tag/0.1.1