Skip to content

Commit 91b1caa

Browse files
committed
address comment: update to allowed username
1 parent 0b9c32f commit 91b1caa

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/tools/args.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { z, type ZodString } from "zod";
33
const NO_UNICODE_REGEX = /^[\x20-\x7E]*$/;
44
export const NO_UNICODE_ERROR = "String cannot contain special characters or Unicode symbols";
55

6-
const ALLOWED_NAME_CHARACTERS_REGEX = /^[a-zA-Z0-9._-]+$/;
7-
export const ALLOWED_NAME_CHARACTERS_ERROR = " can only contain letters, numbers, dots, hyphens, and underscores";
6+
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";
88

99
const ALLOWED_REGION_CHARACTERS_REGEX = /^[a-zA-Z0-9_-]+$/;
1010
export const ALLOWED_REGION_CHARACTERS_ERROR = "Region can only contain letters, numbers, hyphens, and underscores";
@@ -51,7 +51,7 @@ export const AtlasArgs = {
5151
.string()
5252
.min(1, "Username is required")
5353
.max(100, "Username must be 100 characters or less")
54-
.regex(ALLOWED_NAME_CHARACTERS_REGEX, "Username " + ALLOWED_NAME_CHARACTERS_ERROR),
54+
.regex(ALLOWED_USERNAME_CHARACTERS_REGEX, "Username " + ALLOWED_USERNAME_CHARACTERS_ERROR),
5555

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

tests/unit/args.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
AtlasArgs,
44
CommonArgs,
55
ALLOWED_PROJECT_NAME_CHARACTERS_ERROR,
6-
ALLOWED_NAME_CHARACTERS_ERROR,
6+
ALLOWED_USERNAME_CHARACTERS_ERROR,
77
ALLOWED_REGION_CHARACTERS_ERROR,
88
ALLOWED_CLUSTER_NAME_CHARACTERS_ERROR,
99
NO_UNICODE_ERROR,
@@ -195,8 +195,8 @@ describe("Tool args", () => {
195195
expect(() => schema.parse(longUsername)).toThrow("Username must be 100 characters or less");
196196

197197
// Invalid characters
198-
expect(() => schema.parse("user@name")).toThrow("Username " + ALLOWED_NAME_CHARACTERS_ERROR);
199-
expect(() => schema.parse("user name")).toThrow("Username " + ALLOWED_NAME_CHARACTERS_ERROR);
198+
expect(() => schema.parse("user@name")).toThrow("Username " + ALLOWED_USERNAME_CHARACTERS_ERROR);
199+
expect(() => schema.parse("user name")).toThrow("Username " + ALLOWED_USERNAME_CHARACTERS_ERROR);
200200
});
201201

202202
it("should accept exactly 100 characters", () => {
@@ -402,7 +402,7 @@ 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_NAME_CHARACTERS_ERROR);
405+
expect(() => AtlasArgs.username().parse("invalid name")).toThrow("Username " + ALLOWED_USERNAME_CHARACTERS_ERROR);
406406
});
407407
});
408408
});

0 commit comments

Comments
 (0)