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

fix: checks tip input re:#1889 #1947

Merged
merged 1 commit into from Sep 12, 2018

Conversation

Projects
None yet
2 participants
@jessopb
Contributor

jessopb commented Sep 8, 2018

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.

@jessopb jessopb changed the title from checks tip input to fix: checks tip input re:#1889 Sep 8, 2018

@@ -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})?)$/)) {

This comment has been minimized.

@seanyesmunt

seanyesmunt Sep 10, 2018

Member

I think it would be simpler to just do

if (tipAmount < 0.00000001) {

}
@seanyesmunt

seanyesmunt Sep 10, 2018

Member

I think it would be simpler to just do

if (tipAmount < 0.00000001) {

}
@jessopb

This comment has been minimized.

Show comment
Hide comment
@jessopb

jessopb Sep 11, 2018

Contributor

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.

Contributor

jessopb commented Sep 11, 2018

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.

@lbry-bot lbry-bot assigned seanyesmunt and unassigned seanyesmunt Sep 12, 2018

@seanyesmunt seanyesmunt merged commit 923fac1 into lbryio:master Sep 12, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

@jessopb jessopb deleted the jessopb:fixTipModal branch Sep 13, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment