Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Add validation for reference field
Browse files Browse the repository at this point in the history
  • Loading branch information
yasharAyari committed May 17, 2018
1 parent 503ec22 commit 101c078
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"Lisk Website": "Lisk Website",
"Login": "Login",
"Mainnet": "Mainnet",
"Maximum length of 64 characters is exceeded.": "Maximum length of 64 characters is exceeded.",
"Maximum of {{n}} votes exceeded.": "Maximum of {{n}} votes exceeded.",
"Maximum of {{n}} votes in one transaction exceeded.": "Maximum of {{n}} votes in one transaction exceeded.",
"Message": "Message",
Expand Down Expand Up @@ -121,7 +122,7 @@
"Recipient Address": "Recipient Address",
"Recipient PublicKey": "Recipient PublicKey",
"Redo": "Redo",
"Reference (If you use this field, your transaction fee will be 0.2 LSK)": "Reference (If you use this field, your transaction fee will be 0.2 LSK)",
"Reference": "Reference",
"Register": "Register",
"Register Second Passphrase": "Register Second Passphrase",
"Register as delegate": "Register as delegate",
Expand Down Expand Up @@ -189,6 +190,7 @@
"Uptime": "Uptime",
"Upvotes:": "Upvotes:",
"Username": "Username",
"Using a reference will cost an additional fee of 0.1 LSK. Your total transaction fee will be 0.2 LSK if you choose to use a reference.": "Using a reference will cost an additional fee of 0.1 LSK. Your total transaction fee will be 0.2 LSK if you choose to use a reference.",
"Verify message": "Verify message",
"Version": "Version",
"View": "View",
Expand Down
7 changes: 7 additions & 0 deletions src/components/send/send.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@
line-height: 14px;
color: grey;
}

.notice {
float: left;
margin-right: 10px;
display: inline-block;
margin-top: -3px;
}
9 changes: 8 additions & 1 deletion src/components/send/send.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import Input from 'react-toolbox/lib/input';
import { IconMenu, MenuItem } from 'react-toolbox/lib/menu';
import FontIcon from 'react-toolbox/lib/font_icon';
import { fromRawLsk, toRawLsk } from '../../utils/lsk';
import AuthInputs from '../authInputs';
import ActionBar from '../actionBar';
Expand Down Expand Up @@ -64,6 +65,8 @@ class Send extends React.Component {
return this.props.t('Insufficient funds');
} else if (name === 'amount' && value === '0') {
return this.props.t('Zero not allowed');
} else if (name === 'reference' && value.length > 64) {
return this.props.t('Maximum length of 64 characters is exceeded.');
}
return undefined;
}
Expand Down Expand Up @@ -106,12 +109,16 @@ class Send extends React.Component {
value={this.state.amount.value}
onChange={this.handleChange.bind(this, 'amount')} />
<Input
label={this.props.t('Reference (If you use this field, your transaction fee will be 0.2 LSK)')}
label={this.props.t('Reference')}
required={false}
className='reference'
error={this.state.reference.error}
value={this.state.reference.value}
onChange={this.handleChange.bind(this, 'reference')} />
{this.state.reference.value.length > 0 ? <div>
<FontIcon className={styles.notice} value='error_outline' />
{this.props.t('Using a reference will cost an additional fee of 0.1 LSK. Your total transaction fee will be 0.2 LSK if you choose to use a reference.')}
</div> : null }
<AuthInputs
passphrase={this.state.passphrase}
secondPassphrase={this.state.secondPassphrase}
Expand Down

0 comments on commit 101c078

Please sign in to comment.