fix(MintToken): Validation rules reviewed
- Updated name and description regex rules. - Extended name and symbol validation when retry minting to allow same text if we are in edition mode. Fixes #10860
This commit is contained in:
parent
7d551b8311
commit
5e4164e2e6
|
@ -180,6 +180,9 @@ SettingsPageLayout {
|
|||
newTokenView,
|
||||
{
|
||||
isAssetView: d.isAssetType,
|
||||
referenceName: d.currentToken.name,
|
||||
referenceSymbol: d.currentToken.symbol,
|
||||
validationMode: StatusInput.ValidationMode.Always,
|
||||
asset: d.currentToken
|
||||
},
|
||||
StackView.Immediate)
|
||||
|
@ -199,6 +202,9 @@ SettingsPageLayout {
|
|||
newTokenView,
|
||||
{
|
||||
isAssetView: d.isAssetType,
|
||||
referenceName: d.currentToken.name,
|
||||
referenceSymbol: d.currentToken.symbol,
|
||||
validationMode: StatusInput.ValidationMode.Always,
|
||||
collectible: d.currentToken
|
||||
},
|
||||
StackView.Immediate)
|
||||
|
@ -244,6 +250,9 @@ SettingsPageLayout {
|
|||
property CollectibleObject collectible: CollectibleObject{}
|
||||
property AssetObject asset: AssetObject{}
|
||||
property bool isAssetView: false
|
||||
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
|
||||
property string referenceName: ""
|
||||
property string referenceSymbol: ""
|
||||
|
||||
width: root.viewWidth
|
||||
spacing: Style.current.padding
|
||||
|
@ -277,14 +286,20 @@ SettingsPageLayout {
|
|||
id: newCollectibleView
|
||||
|
||||
isAssetView: false
|
||||
validationMode: !_colLayout.isAssetView ? _colLayout.validationMode : StatusInput.ValidationMode.OnlyWhenDirty
|
||||
collectible: _colLayout.collectible
|
||||
referenceName: _colLayout.referenceName
|
||||
referenceSymbol: _colLayout.referenceSymbol
|
||||
}
|
||||
|
||||
CustomCommunityNewTokenView {
|
||||
id: newAssetView
|
||||
|
||||
isAssetView: true
|
||||
validationMode: _colLayout.isAssetView ? _colLayout.validationMode : StatusInput.ValidationMode.OnlyWhenDirty
|
||||
asset: _colLayout.asset
|
||||
referenceName: _colLayout.referenceName
|
||||
referenceSymbol: _colLayout.referenceSymbol
|
||||
}
|
||||
|
||||
component CustomCommunityNewTokenView: CommunityNewTokenView {
|
||||
|
|
|
@ -22,11 +22,16 @@ StatusScrollView {
|
|||
|
||||
property int viewWidth: 560 // by design
|
||||
property bool isAssetView: false
|
||||
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
|
||||
property var tokensModel
|
||||
|
||||
property CollectibleObject collectible: CollectibleObject{}
|
||||
property AssetObject asset: AssetObject{}
|
||||
|
||||
// Used for reference validation when editing a failed deployment
|
||||
property string referenceName: ""
|
||||
property string referenceSymbol: ""
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
|
@ -103,9 +108,19 @@ StatusScrollView {
|
|||
text: root.isAssetView ? asset.name : collectible.name
|
||||
charLimit: 15
|
||||
placeholderText: qsTr("Name")
|
||||
validationMode: root.validationMode
|
||||
minLengthValidator.errorMessage: qsTr("Please name your token name (use A-Z and 0-9, hyphens and underscores only)")
|
||||
regexValidator.errorMessage: qsTr("Your token name contains invalid characters (use A-Z and 0-9, hyphens and underscores only)")
|
||||
extraValidator.validate: function (value) { return !SQUtils.ModelUtils.contains(root.tokensModel, "name", nameInput.text) }
|
||||
extraValidator.validate: function (value) {
|
||||
// If minted failed, we can retry same deployment, so same name allowed
|
||||
var allowRepeatedName = (root.isAssetView ? asset.deployState : collectible.deployState) === Constants.ContractTransactionStatus.Failed
|
||||
if(allowRepeatedName)
|
||||
if(nameInput.text === root.referenceName)
|
||||
return true
|
||||
|
||||
// Otherwise, no repeated names allowed:
|
||||
return !SQUtils.ModelUtils.contains(root.tokensModel, "name", nameInput.text)
|
||||
}
|
||||
extraValidator.errorMessage: qsTr("You have used this token name before")
|
||||
|
||||
onTextChanged: {
|
||||
|
@ -128,8 +143,9 @@ StatusScrollView {
|
|||
input.placeholder.verticalAlignment: Qt.AlignTop
|
||||
minimumHeight: 108
|
||||
maximumHeight: minimumHeight
|
||||
validationMode: root.validationMode
|
||||
minLengthValidator.errorMessage: qsTr("Please enter a token description")
|
||||
regexValidator.regularExpression: Constants.regularExpressions.asciiPrintable
|
||||
regexValidator.regularExpression: Constants.regularExpressions.ascii
|
||||
regexValidator.errorMessage: qsTr("Only A-Z, 0-9 and standard punctuation allowed")
|
||||
|
||||
onTextChanged: {
|
||||
|
@ -147,10 +163,20 @@ StatusScrollView {
|
|||
text: root.isAssetView ? asset.symbol : collectible.symbol
|
||||
charLimit: 6
|
||||
placeholderText: qsTr("e.g. DOODLE")
|
||||
validationMode: root.validationMode
|
||||
minLengthValidator.errorMessage: qsTr("Please enter your token symbol (use A-Z only)")
|
||||
regexValidator.errorMessage: qsTr("Your token symbol contains invalid characters (use A-Z only)")
|
||||
regexValidator.regularExpression: Constants.regularExpressions.capitalOnly
|
||||
extraValidator.validate: function (value) { return !SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) }
|
||||
extraValidator.validate: function (value) {
|
||||
// If minted failed, we can retry same deployment, so same symbol allowed
|
||||
var allowRepeatedName = (root.isAssetView ? asset.deployState : collectible.deployState) === Constants.ContractTransactionStatus.Failed
|
||||
if(allowRepeatedName)
|
||||
if(symbolInput.text === root.referenceSymbol)
|
||||
return true
|
||||
|
||||
// Otherwise, no repeated names allowed:
|
||||
return !SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text)
|
||||
}
|
||||
extraValidator.errorMessage: qsTr("You have used this token symbol before")
|
||||
|
||||
onTextChanged: {
|
||||
|
@ -322,7 +348,7 @@ StatusScrollView {
|
|||
},
|
||||
StatusRegularExpressionValidator {
|
||||
id: regexValidatorItem
|
||||
regularExpression: Constants.regularExpressions.alphanumerical
|
||||
regularExpression: Constants.regularExpressions.alphanumericalExpanded
|
||||
},
|
||||
StatusValidator {
|
||||
id: extraValidatorItem
|
||||
|
|
Loading…
Reference in New Issue