fix(@desktop/wallet): account name character limit not enforced

Closes #10281
This commit is contained in:
Sale Djenic 2023-04-13 13:31:04 +02:00 committed by saledjenic
parent b77c0f13a9
commit 1225a71877
3 changed files with 21 additions and 2 deletions

View File

@ -35,6 +35,7 @@ Item {
accountName.text = root.store.addAccountModule.accountName
accountName.input.edit.forceActiveFocus()
accountName.validate(true)
}
QtObject {
@ -101,6 +102,7 @@ Item {
anchors.horizontalCenter: parent.horizontalCenter
placeholderText: qsTr("Enter an account name...")
label: qsTr("Name")
charLimit: 20
text: root.store.addAccountModule.accountName
input.isIconSelectable: true
input.leftPadding: Style.current.padding
@ -120,6 +122,16 @@ Item {
d.openEmojiPopup(false)
}
}
validators: [
StatusMinLengthValidator {
minLength: 1
errorMessage: Utils.getErrorMessage(accountName.errors, qsTr("wallet account name"))
},
StatusRegularExpressionValidator {
regularExpression: Constants.regularExpressions.alphanumerical
errorMessage: Constants.errorMessages.alphanumericalRegExp
}
]
onTextChanged: {
root.store.addAccountModule.accountName = text
@ -128,6 +140,10 @@ Item {
onKeyPressed: {
root.store.submitAddAccount(event)
}
onValidChanged: {
root.store.accountNameIsValid = accountName.valid
}
}
StatusColorSelectorGrid {

View File

@ -23,6 +23,7 @@ QtObject {
property bool editMode: root.addAccountModule.editMode
property bool disablePopup: root.addAccountModule.disablePopup
property bool accountNameIsValid: false
property bool enteredSeedPhraseIsValid: false
property bool enteredPrivateKeyIsValid: false
property bool addingNewMasterKeyConfirmed: false
@ -195,7 +196,7 @@ QtObject {
}
if (root.editMode) {
return root.addAccountModule.accountName !== "" &&
return root.accountNameIsValid &&
root.addAccountModule.accountName !== root.getStoredAccountName() ||
root.addAccountModule.selectedColor !== "" &&
root.addAccountModule.selectedColor !== root.getStoredSelectedColor() ||
@ -203,7 +204,7 @@ QtObject {
root.addAccountModule.selectedEmoji !== root.getStoredSelectedEmoji()
}
let valid = root.addAccountModule.accountName !== "" &&
let valid = root.accountNameIsValid &&
root.addAccountModule.selectedColor !== "" &&
root.addAccountModule.selectedEmoji !== ""

View File

@ -579,12 +579,14 @@ QtObject {
}
readonly property QtObject regularExpressions: QtObject {
readonly property var alphanumerical: /^$|^[a-zA-Z0-9]+$/
readonly property var alphanumericalExpanded: /^$|^[a-zA-Z0-9\-_ ]+$/
readonly property var asciiPrintable: /^$|^[!-~]+$/
readonly property var ascii: /^$|^[\x00-\x7F]+$/
}
readonly property QtObject errorMessages: QtObject {
readonly property string alphanumericalRegExp: qsTr("Only letters and numbers allowed")
readonly property string alphanumericalExpandedRegExp: qsTr("Only letters, numbers, underscores, whitespaces and hyphens allowed")
readonly property string asciiRegExp: qsTr("Only letters, numbers and ASII characters allowed")
}