aranlucas / react-hook-form-mantine

React Hook Form bindings for Mantine components
https://aranlucas.github.io/react-hook-form-mantine/
92 stars 13 forks source link

NumberInput no longer automatically convert string to integer #20

Closed ringuralte closed 1 year ago

ringuralte commented 1 year ago

Hi, so I don't know if it's a problem with my project cause I have to manually update mantine to v7 along with this package, but before the NumberInput component automatically converts values to number when zod expects z.number(), but now it's showing the error Expected number, received string

Update: This problems only occur if you want to put the default value of the number as undefined and then put a number as the input. If you give a number eg: 0, as the default value, then you won't run into this problem. Putting 0 as the default value is kinda annoying though.

ringuralte commented 1 year ago

Using zod's coerce fixes my problem. https://zod.dev/?id=coercion-for-primitives