Open OlliL opened 5 months ago
I would like to work on this. Can you assign me this issue ^^
Any news about getting this into main?
Any news about getting this into main?
nothing yet
Quite a lot of time has passed by for this rather trivial issue. I was just wondering - what holding the pull request back from getting merged?
Quite a lot of time has passed by for this rather trivial issue. I was just wondering - what holding the pull request back from getting merged?
@colinhacks
If you want to enforce a max amount of decimal places you can use
multipleOf()
. If you want to enforce a max amount of 3 decimal places you can usemultipleOf(0.001)
which works perfectly fine.So while this works up to 6 decimals (
multipleOf(0.000001)
) fine, it stops working with 7 decimals and above. To make it parse with 7 decimal places and above, the number to parse must contain exactly the amount of decimal places as specified in multpleOf.A small showcase:The bug happens because of how JavaScript handles complex numbers. Zods internal function floatSafeRemainder tries to parse its parameter. While it works fine with 0.000001, it stops working fine with 7 and more decimals because then step becomes 1e-7 instead of 0.0000001 and the parsing logic stops working.
A possible fix which accounts exponential representation of complex numbers could be the following drop-in replacement logic for stepDecCount:
Seems to work fine for me.....