diff --git a/ui/app/AppLayouts/Profile/popups/RenameAccontModal.qml b/ui/app/AppLayouts/Profile/popups/RenameAccontModal.qml index 48d1794f2a..6ef4358ebd 100644 --- a/ui/app/AppLayouts/Profile/popups/RenameAccontModal.qml +++ b/ui/app/AppLayouts/Profile/popups/RenameAccontModal.qml @@ -69,15 +69,15 @@ StatusModal { } validators: [ StatusMinLengthValidator { - errorMessage: qsTr("You need to enter an account name") - minLength: 1 + errorMessage: qsTr("Account name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength) + minLength: Constants.addAccountPopup.keyPairAccountNameMinLength }, StatusRegularExpressionValidator { regularExpression: /^[^<>]+$/ errorMessage: qsTr("This is not a valid account name") } ] - charLimit: 40 + charLimit: 20 } StatusColorSelectorGrid { diff --git a/ui/imports/shared/popups/addaccount/states/EnterKeypairName.qml b/ui/imports/shared/popups/addaccount/states/EnterKeypairName.qml index 40d96cf661..258e00ff1d 100644 --- a/ui/imports/shared/popups/addaccount/states/EnterKeypairName.qml +++ b/ui/imports/shared/popups/addaccount/states/EnterKeypairName.qml @@ -5,6 +5,7 @@ import QtQuick.Layouts 1.14 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 import StatusQ.Controls 0.1 +import StatusQ.Controls.Validators 0.1 import utils 1.0 @@ -43,6 +44,13 @@ Item { onKeyPressed: { root.store.submitPopup(event) } + + validators: [ + StatusMinLengthValidator { + errorMessage: qsTr("Keypair name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength) + minLength: Constants.addAccountPopup.keyPairAccountNameMinLength + } + ] } StatusBaseText { diff --git a/ui/imports/shared/popups/addaccount/states/Main.qml b/ui/imports/shared/popups/addaccount/states/Main.qml index d892b1ec8a..1b86182c58 100644 --- a/ui/imports/shared/popups/addaccount/states/Main.qml +++ b/ui/imports/shared/popups/addaccount/states/Main.qml @@ -126,8 +126,8 @@ Item { } validators: [ StatusMinLengthValidator { - minLength: 1 - errorMessage: Utils.getErrorMessage(accountName.errors, qsTr("wallet account name")) + errorMessage: qsTr("Account name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength) + minLength: Constants.addAccountPopup.keyPairAccountNameMinLength }, StatusRegularExpressionValidator { regularExpression: Constants.regularExpressions.alphanumericalWithSpace diff --git a/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml b/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml index 6f574a54b0..4ba52b76f9 100644 --- a/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml +++ b/ui/imports/shared/popups/addaccount/stores/AddAccountStore.qml @@ -236,7 +236,7 @@ BasePopupStore { root.privateKeyAccAddress.loaded && !root.privateKeyAccAddress.alreadyCreated && root.privateKeyAccAddress.address !== "" && - root.addAccountModule.newKeyPairName !== "" + root.addAccountModule.newKeyPairName.length >= Constants.addAccountPopup.keyPairAccountNameMinLength } } @@ -246,12 +246,12 @@ BasePopupStore { root.privateKeyAccAddress.loaded && !root.privateKeyAccAddress.alreadyCreated && root.privateKeyAccAddress.address !== "" && - root.addAccountModule.newKeyPairName !== "" + root.addAccountModule.newKeyPairName.length >= Constants.addAccountPopup.keyPairAccountNameMinLength } if (root.currentState.stateType === Constants.addAccountPopup.state.enterSeedPhrase) { return root.enteredSeedPhraseIsValid && - root.addAccountModule.newKeyPairName !== "" + root.addAccountModule.newKeyPairName.length >= Constants.addAccountPopup.keyPairAccountNameMinLength } @@ -276,7 +276,7 @@ BasePopupStore { } if (root.currentState.stateType === Constants.addAccountPopup.state.enterKeypairName) { - return root.addAccountModule.newKeyPairName !== "" + return root.addAccountModule.newKeyPairName.length >= Constants.addAccountPopup.keyPairAccountNameMinLength } return true diff --git a/ui/imports/shared/popups/common/EnterPrivateKey.qml b/ui/imports/shared/popups/common/EnterPrivateKey.qml index f50ee43ad7..ef4c6e9738 100644 --- a/ui/imports/shared/popups/common/EnterPrivateKey.qml +++ b/ui/imports/shared/popups/common/EnterPrivateKey.qml @@ -176,6 +176,13 @@ Item { onKeyPressed: { root.store.submitPopup(event) } + + validators: [ + StatusMinLengthValidator { + errorMessage: qsTr("Keypair name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength) + minLength: Constants.addAccountPopup.keyPairAccountNameMinLength + } + ] } StatusBaseText { diff --git a/ui/imports/shared/popups/common/EnterSeedPhrase.qml b/ui/imports/shared/popups/common/EnterSeedPhrase.qml index a9cffcf360..86eb636acc 100644 --- a/ui/imports/shared/popups/common/EnterSeedPhrase.qml +++ b/ui/imports/shared/popups/common/EnterSeedPhrase.qml @@ -88,6 +88,13 @@ Item { root.store.addAccountModule.newKeyPairName = text } + validators: [ + StatusMinLengthValidator { + errorMessage: qsTr("Keypair name must be at least %n character(s)", "", Constants.addAccountPopup.keyPairAccountNameMinLength) + minLength: Constants.addAccountPopup.keyPairAccountNameMinLength + } + ] + onKeyPressed: { root.store.submitPopup(event) } diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 6abc200292..285eb7d6f5 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -733,6 +733,7 @@ QtObject { readonly property int labelFontSize2: 13 readonly property int footerButtonsHeight: 44 readonly property int keyPairNameMaxLength: 20 + readonly property int keyPairAccountNameMinLength: 5 readonly property int stepperWidth: 242 readonly property int stepperHeight: 30