fdarian / prisma-generator-drizzle

A Prisma generator for generating Drizzle schema with ease
88 stars 10 forks source link

fix: picklist was validated after coerce to boolean #61

Closed jansedlon closed 4 weeks ago

jansedlon commented 4 weeks ago

This PR slightly improves using the api from union([literal(), literal()]) because unions are usually used when parsing different data types into picklist.

It also fixes the usage of using true | false values.

At least on my machine, values that are boolean (eg. verbose) were not parsed correctly and always threw an error saying that it expected 'true' | 'false' but got false.

I figured that it was because in coerce method, the callback is executed first and then the validation happens. Which means that it was coerced to boolean and then it was trying to validate two literals which always failed.

jansedlon commented 4 weeks ago

@farreldarian If you want, i'd be happy to refactor the whole config to valibot v0.31.0 which introduced breaking changes and the whole paradigm changed into using pipe function. It's still in beta though but at least in my app it's okay

fdarian commented 4 weeks ago

It's still in beta though but at least in my app it's okay

Why not 🚀