-
-
Notifications
You must be signed in to change notification settings - Fork 189
Donation Values Treated as Strings #243
Comments
I am just getting my local instance setup but I'd like to take a crack at this if no one minds. |
just saw this comment.. I have just made PR on this. Can you please look into it and let me know if you have other approaches to fix this issue? Thanks! |
Yeah that looks fine. Sorry @cjhaviland, hope you can find something else you'd like to try. Edit: actually, donation values are also summed on the server (see #245) to generate the receipt email, guess this will be a problem there too so maybe it's better to make sure they're stored as numbers instead. |
I think wrapping it in a number should be fine, but like I said I haven't gotten a chance to get everything up and running yet to look. I would definitely check that there is validation on the input so we can only accept numbers. |
The value input on the client and the mongoose schema are both type number. Not sure why this is a problem, and only with user entered data (seems fine with seed data). |
I believe that redux-form is returning values as string. (In components/DonationCreate.js, we are converting item.value to Number in order to calculate total item amount due to this reason). |
I think it would make the backend more robust not to assume that the (acc, item) => {
// TODO: check if Number(item.value) is NaN. If so throw BadRequestError
return acc + Number(item.value)
} @cjhaviland, do you want to take this? |
We still need to validate that the value properties for the items are numeric on the server. If anyone ones to take this please leave a comment. |
I should be able to work on this over the next few days! |
Looks like the donation values are being concatenated instead of being summed up.
The text was updated successfully, but these errors were encountered: