Skip to content

Commit e24937a

Browse files
committed
address comment: update error messages
1 parent 91b1caa commit e24937a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/tools/args.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const NO_UNICODE_REGEX = /^[\x20-\x7E]*$/;
44
export const NO_UNICODE_ERROR = "String cannot contain special characters or Unicode symbols";
55

66
const ALLOWED_USERNAME_CHARACTERS_REGEX = /^[a-zA-Z0-9._-]+$/;
7-
export const ALLOWED_USERNAME_CHARACTERS_ERROR = " can only contain letters, numbers, dots, hyphens, and underscores";
7+
export const ALLOWED_USERNAME_CHARACTERS_ERROR =
8+
"Username can only contain letters, numbers, dots, hyphens, and underscores";
89

910
const ALLOWED_REGION_CHARACTERS_REGEX = /^[a-zA-Z0-9_-]+$/;
1011
export const ALLOWED_REGION_CHARACTERS_ERROR = "Region can only contain letters, numbers, hyphens, and underscores";
@@ -37,7 +38,7 @@ export const AtlasArgs = {
3738
.string()
3839
.min(1, "Cluster name is required")
3940
.max(64, "Cluster name must be 64 characters or less")
40-
.regex(ALLOWED_CLUSTER_NAME_CHARACTERS_REGEX, "Cluster name " + ALLOWED_CLUSTER_NAME_CHARACTERS_ERROR),
41+
.regex(ALLOWED_CLUSTER_NAME_CHARACTERS_REGEX, ALLOWED_CLUSTER_NAME_CHARACTERS_ERROR),
4142

4243
projectName: (): z.ZodString =>
4344
z
@@ -51,7 +52,7 @@ export const AtlasArgs = {
5152
.string()
5253
.min(1, "Username is required")
5354
.max(100, "Username must be 100 characters or less")
54-
.regex(ALLOWED_USERNAME_CHARACTERS_REGEX, "Username " + ALLOWED_USERNAME_CHARACTERS_ERROR),
55+
.regex(ALLOWED_USERNAME_CHARACTERS_REGEX, ALLOWED_USERNAME_CHARACTERS_ERROR),
5556

5657
ipAddress: (): z.ZodString => z.string().ip({ version: "v4" }),
5758

tests/unit/args.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ describe("Tool args", () => {
402402
expect(() => AtlasArgs.username().parse("a".repeat(101))).toThrow(
403403
"Username must be 100 characters or less"
404404
);
405-
expect(() => AtlasArgs.username().parse("invalid name")).toThrow("Username " + ALLOWED_USERNAME_CHARACTERS_ERROR);
405+
expect(() => AtlasArgs.username().parse("invalid name")).toThrow(
406+
"Username " + ALLOWED_USERNAME_CHARACTERS_ERROR
407+
);
406408
});
407409
});
408410
});

0 commit comments

Comments
 (0)