Skip to content

Commit 9156576

Browse files
committed
Fix validation for app service name
1 parent 752a252 commit 9156576

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/util/ValidationUtils.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ public static void validateAppServiceName(String subscriptionId, String appServi
5858
if (StringUtils.isEmpty(subscriptionId)) {
5959
throw new IllegalArgumentException(message("appService.subscription.validate.empty"));
6060
}
61+
if(StringUtils.isEmpty(appServiceName)){
62+
throw new IllegalArgumentException(message("appService.name.validate.empty"));
63+
}
64+
if (appServiceName.length() < 2 || appServiceName.length() > 60) {
65+
throw new IllegalArgumentException(message("appService.name.validate.length"));
66+
}
6167
if (!isValidAppServiceName(appServiceName)) {
62-
throw new IllegalArgumentException(message("appService.subscription.validate.invalidName"));
68+
throw new IllegalArgumentException(message("appService.name.validate.invalidName"));
6369
}
6470
final CheckNameAvailabilityResultEntity result = Azure.az(AzureAppService.class).checkNameAvailability(subscriptionId, appServiceName);
6571
if (!result.isAvailable()) {

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/resources/com/microsoft/intellij/ui/messages/messages.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,9 @@ appService.deploy.hint.succeed=Deploy succeed
13671367
appService.deploy.hint.failed=Deploy failed!
13681368
appService.runProcess.hint.processTerminated=The process has been terminated
13691369
appService.subscription.validate.empty=Subscription can not be null
1370-
appService.subscription.validate.invalidName=App service names only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than 60 chars.
1370+
appService.name.validate.empty=App service names can not be null
1371+
appService.name.validate.length=App service names be at least 2 characters, and be fewer than 60 characters
1372+
appService.name.validate.invalidName=App service names only allow alphanumeric characters and hyphens, cannot start or end in a hyphen, and must be less than 60 chars.
13711373
appService.logStreaming.hint.connect=Connecting to log stream...
13721374
appService.logStreaming.hint.notStart=Streaming log is not started.
13731375
appService.logStreaming.hint.disconnected=Disconnected from log-streaming service.

0 commit comments

Comments
 (0)