-
Notifications
You must be signed in to change notification settings - Fork 27
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
Return number when mask = false #27
Comments
You are rights. Will parse it to a float in the next release. |
Fixed in the Line 133 in f5731be
Thanks for reporting! |
Not a big issue but I wonder if it'd be better to check for the |
So this |
I was referring to the v-model modifier: https://v3.vuejs.org/guide/forms.html#number @gigioSouza Do you think it's reasonable to expect users to use |
@AndrolGenhald actually I myself would rather use I want the component to present my numeric the data with a mask, so I want to deal with numbers by default and opt-in if I want to handle the masked value. I'll fork and propose a Pull Request about it. |
I will reopen this until we ship a new release about the changes discussed until now. |
I think the main goal here is to define what would be the default return type when I like to follow what Vue has to offer. This is how Vue deals with the problem and solving it with the On the other hand, I think that the default return type should be a We could even use a property to solve this, but something like |
@jonathanpmartins I was testing the second approach. So the config price is a number by default <money3 v-model="price" :config="config" /> price is a masked string due to the <money3 v-model.masked="price" :config="config" /> |
The If the implementation changes in favor of the <money3 v-model="price" /> With the number modifier it will return a typeof <money3 v-model.number="price" /> If you really need a float after this change, the annoying refactoring would be change all your |
Currency data are used for calculation, it bothered me having to parse the data back to numbers. I think it doesn't make sense to return a string with fixed floating number. |
Perhaps we should introduce a new property called
This will not create a break change and will introduce the possibility to have a fixed string returned. What do you think about it? |
Correct, eg whether to return
I mostly agree, but the reason I bring it up is because many applications that deal with currency want fixed precision, and having to convert from a float back to a string is also annoying, with the additional annoyance that in some cases the floating point format could cause a loss of precision. It's unlikely to affect most use cases since JavaScript uses a 64 bit floating point format, but it's still possible.
Probably, but the same could be said of the previous change to return a number instead of a string.
This is the other reason I lean more towards wanting it to return a string, it's the same way other inputs work. It's the same way a
That seems reasonable. Using |
I'm much more inclined to use the I don't think that this refactoring ( |
The only scenario I can think of losing precision is: |
64-bit floating point values can store 15-17 decimal digits before losing precision. If you want to have tens of trillions, that's 14 digits, add in cents and it's 16, which could start to lose precision. Numbers this high don't show up too often in US dollars, but you can get values like that when talking about national budgets. I'd guess in other countries with lower valued currencies it could be worse. |
…oat number even if masked property is true
I will not release a major 4.0 because I don't think it will ever be one. The idea is to follow Vue on their major release numbers. If Vue decides to release a major 4.0 version tomorrow I will probably create a new repository/project called This is what I was planing to do until now. That said, now that I think more about it, I feel that I need to plan a project rename to accomplish modern standards. Will be much better to keep everything in one repository for so many reasons.... Or we can forever stay For the time being I will release a |
v-money3/src/utils.js
Line 108 in a3d0ff7
I was expecting to receive a number type when setting
masked: false
, but instead it returns a string.Shouldn't it return a number?
The text was updated successfully, but these errors were encountered: