feat(ProfileShowcase): Update display name validator error messages

This commit is contained in:
Alex Jbanca 2024-02-07 10:13:20 +02:00 committed by Alex Jbanca
parent e805dd0b9c
commit 610a9dc115
1 changed files with 14 additions and 23 deletions

View File

@ -538,48 +538,39 @@ QtObject {
readonly property list<StatusValidator> displayName: [ readonly property list<StatusValidator> displayName: [
StatusValidator { StatusValidator {
name: "startsWithSpaceValidator" name: "startsWithSpaceValidator"
validate: function (t) { return !t.startsWith(" ") } validate: function (t) { return !(t.startsWith(" ") || t.endsWith(" "))}
errorMessage: qsTr("Usernames starting with whitespace are not allowed") errorMessage: qsTr("Display Names cant start or end with a space")
}, },
StatusRegularExpressionValidator { StatusRegularExpressionValidator {
regularExpression: regularExpressions.alphanumericalExpanded regularExpression: regularExpressions.alphanumericalExpanded
errorMessage: errorMessages.alphanumericalExpandedRegExp errorMessage: qsTr("Invalid characters (use A-Z and 0-9, hyphens and underscores only)")
}, },
StatusMinLengthValidator { StatusMinLengthValidator {
minLength: keypair.nameLengthMin minLength: keypair.nameLengthMin
errorMessage: qsTr("Username must be at least %n character(s)", "", keypair.nameLengthMin) errorMessage: qsTr("Display Names must be at least %n character(s) long", "", keypair.nameLengthMin)
},
StatusValidator {
name: "endsWithSpaceValidator"
validate: function (t) { return !t.endsWith(" ") }
errorMessage: qsTr("Usernames ending with whitespace are not allowed")
}, },
// TODO: Create `StatusMaxLengthValidator` in StatusQ // TODO: Create `StatusMaxLengthValidator` in StatusQ
StatusValidator { StatusValidator {
name: "maxLengthValidator" name: "maxLengthValidator"
validate: function (t) { return t.length <= keypair.nameLengthMax } validate: function (t) { return t.length <= keypair.nameLengthMax }
errorMessage: qsTr("%n character(s) username limit", "", keypair.nameLengthMax) errorMessage: qsTr("Display Names cant be longer than %n character(s)", "", keypair.nameLengthMax)
}, },
StatusValidator { StatusValidator {
name: "endsWith-ethValidator" name: "endsWith-ethValidator"
validate: function (t) { return !t.endsWith("-eth") } validate: function (t) { return !(t.endsWith("-eth") || t.endsWith("_eth") || t.endsWith(".eth")) }
errorMessage: qsTr("Usernames ending with '-eth' are not allowed") errorMessage: qsTr("Display Names cant end in “.eth”, “_eth” or “-eth”")
},
StatusValidator {
name: "endsWith_ethValidator"
validate: function (t) { return !t.endsWith("_eth") }
errorMessage: qsTr("Usernames ending with '_eth' are not allowed")
},
StatusValidator {
name: "endsWith.ethValidator"
validate: function (t) { return !t.endsWith(".eth") }
errorMessage: qsTr("Usernames ending with '.eth' are not allowed")
}, },
StatusValidator { StatusValidator {
name: "isAliasValidator" name: "isAliasValidator"
validate: function (t) { return !globalUtils.isAlias(t) } validate: function (t) { return !globalUtils.isAlias(t) }
errorMessage: qsTr("Sorry, the name you have chosen is not allowed, try picking another username") errorMessage: qsTr("Adjective-animal Display Name formats are not allowed")
} }
// https://github.com/status-im/status-desktop/issues/13434
// StatusValidator {
// name: "isDuplicateInComunitiesValidator"
// validate: function(t) { return !globalUtils.isDuplicatedInComunities(t) }
// errorMessage: qsTr("This Display Name is already in use in one of your joined communities")
// }
] ]
} }