fix: checks tip input re:#1889 #1947

Merged
jessopb merged 1 commit from fixTipModal into master 2018-09-12 17:21:08 +02:00
jessopb commented 2018-09-09 00:21:12 +02:00 (Migrated from github.com)

Issue #1889 mentions the tip input allowing any number of decimal places, far beyond one satoshi.
This should do it. I'm looking for input on the Error message, though.

I also noticed that the field would fail to complain about 5.5.5.5 as an input. That's a bit better now, though not perfect. 5.5. slips by for some reason, but 5.5.5 throws an error.

Issue #1889 mentions the tip input allowing any number of decimal places, far beyond one satoshi. This should do it. I'm looking for input on the Error message, though. I also noticed that the field would fail to complain about 5.5.5.5 as an input. That's a bit better now, though not perfect. 5.5. slips by for some reason, but 5.5.5 throws an error.
neb-b (Migrated from github.com) requested changes 2018-09-10 14:26:43 +02:00
@ -50,6 +50,9 @@ class WalletSendTip extends React.PureComponent<Props, State> {
const { balance } = this.props;
const tipAmount = parseFloat(event.target.value);
let newTipError;
if (!String(tipAmount).match(/^(\d*([.]\d{0,8})?)$/)) {
neb-b (Migrated from github.com) commented 2018-09-10 14:26:39 +02:00

I think it would be simpler to just do

if (tipAmount < 0.00000001) {

}
I think it would be simpler to just do ``` if (tipAmount < 0.00000001) { } ```
jessopb commented 2018-09-11 03:59:24 +02:00 (Migrated from github.com)

I appreciate your patience. I agree - it's pretty ugly to cast to string just to use regex.
I was trying to kill all possible birds, but I may be bikeshedding and overthinking it.
Is there any concern about other invalid inputs, or are those handled on the backend? My console.log tests show other invalid tipAmounts like 2.123456789 (9 decimal places) and 'undefined' (from 5.5.5) being passed as the tipAmount state.

I appreciate your patience. I agree - it's pretty ugly to cast to string just to use regex. I was trying to kill all possible birds, but I may be bikeshedding and overthinking it. Is there any concern about other invalid inputs, or are those handled on the backend? My console.log tests show other invalid tipAmounts like 2.123456789 (9 decimal places) and 'undefined' (from 5.5.5) being passed as the tipAmount state.
neb-b (Migrated from github.com) approved these changes 2018-09-12 07:28:07 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#1947
No description provided.