From a6aa0e0150623e572e5dabfe5485e2fc55538026 Mon Sep 17 00:00:00 2001 From: Tushar Karkera <104358692+TusharKarkera22@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:26:14 +0530 Subject: [PATCH] Make testnet faucet page more efficient by adding input validation #259 --- src/pages/testnet/DevelopersPage.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/pages/testnet/DevelopersPage.vue b/src/pages/testnet/DevelopersPage.vue index e191fdde..d7fa3626 100644 --- a/src/pages/testnet/DevelopersPage.vue +++ b/src/pages/testnet/DevelopersPage.vue @@ -16,6 +16,24 @@ export default { submitting: false, }; }, + computed: { + isCreateAccountButtonDisabled() { + return ( + !this.form.account_name || + !this.form.owner_key || + !this.form.active_key || + this.submitting + ); + }, + isAnyInputInvalid() { + return ( + !this.form.account_name || + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.owner_key) || + !/^EOS[0-9A-Za-z]{50}$/.test(this.form.active_key) + + ); + }, + }, methods: { ...mapActions('testnet', ['faucet', 'evmFaucet', 'account']), async onFaucet() { @@ -85,6 +103,7 @@ q-page.flex.flex-center ref="owner_key" v-model="form.owner_key" color="accent" + :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Owner key']" label="Owner key" outlined ) @@ -92,6 +111,8 @@ q-page.flex.flex-center ref="active_key" v-model="form.active_key" color="accent" + :rules="[ val => /^EOS[0-9A-Za-z]{50}$/.test(val) || 'Please provide a valid Active key']" + label="Active key" outlined ) @@ -101,6 +122,7 @@ q-page.flex.flex-center size="lg" unelevated :loading="submitting" + :disable="isAnyInputInvalid" @click="onAccount" )