Skip to content

Commit c94c605

Browse files
committed
Backport of PR#429
1 parent 7b12d99 commit c94c605

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

Diff for: resources/magento2/validation.properties

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ validator.startWithNumberOrCapitalLetter=The {0} field must start with a number
88
validator.onlyNumbers=The {0} field must contain numbers only
99
validator.mustNotBeNegative={0} must not be negative
1010
validator.identifier=The {0} field must contain letters, numbers, dashes, and underscores only
11+
validator.identifier.colon=The {0} field must contain letters, numbers, colons, dashes, and underscores only
1112
validator.class.isNotValid=The {0} field does not contain a valid class name
1213
validator.class.shouldBeUnique=Duplicated class {0}
1314
validator.namespace.isNotValid=The {0} field does not contain a valid namespace

Diff for: src/com/magento/idea/magento2plugin/actions/generation/dialog/CreateAPluginDialog.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry;
1616
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.BoxNotEmptyRule;
1717
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.DirectoryRule;
18-
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierRule;
18+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierWithColonRule;
1919
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule;
2020
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NumericRule;
2121
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.PhpClassRule;
@@ -88,8 +88,8 @@ public class CreateAPluginDialog extends AbstractDialog {
8888

8989
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
9090
message = {NotEmptyRule.MESSAGE, PLUGIN_NAME})
91-
@FieldValidation(rule = RuleRegistry.IDENTIFIER,
92-
message = {IdentifierRule.MESSAGE, PLUGIN_NAME})
91+
@FieldValidation(rule = RuleRegistry.IDENTIFIER_WITH_COLON,
92+
message = {IdentifierWithColonRule.MESSAGE, PLUGIN_NAME})
9393
private JTextField pluginName;
9494

9595
private JLabel pluginDirectoryName;//NOPMD

Diff for: src/com/magento/idea/magento2plugin/actions/generation/dialog/validator/annotation/RuleRegistry.java

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.CronScheduleRule;
1515
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.DirectoryRule;
1616
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierRule;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.IdentifierWithColonRule;
1718
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.Lowercase;
1819
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NotEmptyRule;
1920
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.NumericRule;
@@ -33,6 +34,7 @@ public enum RuleRegistry {
3334
DIRECTORY(DirectoryRule.class),
3435
PHP_DIRECTORY(PhpDirectoryRule.class),
3536
IDENTIFIER(IdentifierRule.class),
37+
IDENTIFIER_WITH_COLON(IdentifierWithColonRule.class),
3638
PHP_NAMESPACE_NAME(PhpNamespaceNameRule.class),
3739
START_WITH_NUMBER_OR_CAPITAL_LETTER(StartWithNumberOrCapitalLetterRule.class),
3840
ACL_RESOURCE_ID(AclResourceIdRule.class),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule;
2+
3+
import com.magento.idea.magento2plugin.util.RegExUtil;
4+
5+
public class IdentifierWithColonRule implements ValidationRule {
6+
public static final String MESSAGE = "validator.identifier.colon";
7+
private static final ValidationRule INSTANCE = new IdentifierWithColonRule();
8+
9+
@Override
10+
public boolean check(final String value) {
11+
return value.matches(RegExUtil.IDENTIFIER_WITH_COLON);
12+
}
13+
14+
public static ValidationRule getInstance() {
15+
return INSTANCE;
16+
}
17+
}

Diff for: src/com/magento/idea/magento2plugin/util/RegExUtil.java

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class RegExUtil {
2222
public static final String IDENTIFIER
2323
= "[a-zA-Z0-9_\\-]*";
2424

25+
public static final String IDENTIFIER_WITH_COLON
26+
= "[a-zA-Z0-9:_\\-]*";
27+
2528
public static final String LOWER_SNAKE_CASE
2629
= "[a-z][a-z0-9_]*";
2730

0 commit comments

Comments
 (0)