diff --git a/backend/__tests__/utils/validation.spec.ts b/backend/__tests__/utils/validation.spec.ts index 1f5106c44..3176d4229 100644 --- a/backend/__tests__/utils/validation.spec.ts +++ b/backend/__tests__/utils/validation.spec.ts @@ -16,10 +16,6 @@ describe("Validation", () => { name: "valid-name", expected: true, }, - { - name: "valid.name", - expected: true, - }, { name: "thistagnameistoolong", expected: false, @@ -97,7 +93,7 @@ describe("Validation", () => { expected: true, }, { - name: "Fe-rotiq._123._", + name: "Fe-rotiq_123_", expected: true, }, { diff --git a/backend/src/api/routes/users.ts b/backend/src/api/routes/users.ts index 1ccca515e..e889cf4a2 100644 --- a/backend/src/api/routes/users.ts +++ b/backend/src/api/routes/users.ts @@ -83,7 +83,7 @@ const usernameValidation = joi "string.profanity": "The username contains profanity. If you believe this is a mistake, please contact us ", "string.pattern.base": - "Username invalid. Name cannot use special characters or contain more than 16 characters. Can include _ . and - ", + "Username invalid. Name cannot use special characters or contain more than 16 characters. Can include _ and - ", }); const languageSchema = joi diff --git a/backend/src/utils/validation.ts b/backend/src/utils/validation.ts index 26ee57e2a..fe44aec73 100644 --- a/backend/src/utils/validation.ts +++ b/backend/src/utils/validation.ts @@ -8,20 +8,13 @@ export function inRange(value: number, min: number, max: number): boolean { return value >= min && value <= max; } -const VALID_NAME_PATTERN = /^[\da-zA-Z_.-]+$/; +const VALID_NAME_PATTERN = /^[\da-zA-Z_-]+$/; export function isUsernameValid(name: string): boolean { if (_.isNil(name) || !inRange(name.length, 1, 16)) { return false; } - const normalizedName = name.toLowerCase(); - - const beginsWithPeriod = /^\..*/.test(normalizedName); - if (beginsWithPeriod) { - return false; - } - return VALID_NAME_PATTERN.test(name); }