Skip to content

Commit

Permalink
Relax the service name validation to allow one char names
Browse files Browse the repository at this point in the history
  • Loading branch information
sugmanue authored and kstich committed Nov 16, 2023
1 parent e7f833d commit 79ad214
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public static void validateServiceId(String serviceId) {
messages.add(String.format("Must not case-insensitively end with `%s`", suffix));
});

if (serviceId.length() < 2 || serviceId.length() > 50) {
messages.add("Must be between 2 and 50 characters long.");
if (serviceId.isEmpty() || serviceId.length() > 50) {
messages.add("Must be between 1 and 50 characters long.");
}

if (!messages.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ public void noTrailingWhitespace() {
@Test
public void doesNotAllowShortIds() {
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
SdkServiceIdValidator.validateServiceId("F"));
SdkServiceIdValidator.validateServiceId(""));

assertThat(thrown.getMessage(), containsString("2 and 50"));
assertThat(thrown.getMessage(), containsString("1 and 50"));
}

@Test
public void doesNotAllowLongIds() {
IllegalArgumentException thrown = Assertions.assertThrows(IllegalArgumentException.class, () ->
SdkServiceIdValidator.validateServiceId("Foobarbazqux Foobarbazqux Foobarbazqux Foobarbazqux"));

assertThat(thrown.getMessage(), containsString("2 and 50"));
assertThat(thrown.getMessage(), containsString("1 and 50"));
}
}

0 comments on commit 79ad214

Please sign in to comment.