Validate Ethereum addresses in input fields

This commit is contained in:
2019-07-22 17:29:31 +02:00
parent d6d2b1a61c
commit a8ae2b0156
4 changed files with 247 additions and 8 deletions
+7 -2
View File
@@ -1,7 +1,9 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { and, notEmpty } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { isPresent } from '@ember/utils';
import { isAddress } from 'web3-utils';
export default Component.extend({
@@ -9,14 +11,17 @@ export default Component.extend({
attributes: null,
// TODO: add proper address validation
isValidAccount: notEmpty('account'),
isValidAccount: computed('ethAddress', function() {
return isAddress(this.ethAddress);
}),
isValidName: notEmpty('name'),
isValidURL: notEmpty('url'),
isValidGithubUID: notEmpty('github_uid'),
isValidGithubUsername: notEmpty('github_username'),
isValidGiteaUsername: notEmpty('gitea_username'),
isValidWikiUsername: notEmpty('wiki_username'),
isValid: and(
'isValidAccount',
'isValidName',
+15 -5
View File
@@ -1,13 +1,23 @@
import Controller from '@ember/controller';
import { not, notEmpty } from '@ember/object/computed';
// import { computed } from '@ember/object';
import { computed } from '@ember/object';
import { not } from '@ember/object/computed';
import { isAddress } from 'web3-utils';
export default Controller.extend({
ethAddress: null,
// TODO address validation
isValidEthAccount: notEmpty('ethAddress'),
signupButtonDisabled: not('isValidEthAccount')
isValidEthAccount: computed('ethAddress', function() {
return isAddress(this.ethAddress);
}),
signupButtonDisabled: not('isValidEthAccount'),
actions: {
completeSignup() {
}
}
});