From 5bab04a4877945bcfbd14cbbe26f6d1ed40ff73d Mon Sep 17 00:00:00 2001 From: Nivedin <53208152+nivedin@users.noreply.github.com> Date: Tue, 2 Sep 2025 13:48:28 +0530 Subject: [PATCH] feat: allow non-empty shared workspace names (#5363) --- packages/hoppscotch-backend/src/team/team.service.spec.ts | 8 ++++---- packages/hoppscotch-backend/src/team/team.service.ts | 2 +- packages/hoppscotch-common/locales/en.json | 2 +- .../src/helpers/backend/types/TeamName.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/hoppscotch-backend/src/team/team.service.spec.ts b/packages/hoppscotch-backend/src/team/team.service.spec.ts index 44954535..5fa2e2ff 100644 --- a/packages/hoppscotch-backend/src/team/team.service.spec.ts +++ b/packages/hoppscotch-backend/src/team/team.service.spec.ts @@ -361,8 +361,8 @@ describe('renameTeam', () => { ).resolves.toEqualLeft(TEAM_INVALID_ID); }); - test('rejects for new team name length < 6 with TEAM_NAME_INVALID', () => { - const newTeamName = 'smol'; + test('rejects for new team name empty with TEAM_NAME_INVALID', () => { + const newTeamName = ''; // Prisma doesn't care about the team name length, so it will resolve mockPrisma.team.update.mockResolvedValue({ @@ -668,8 +668,8 @@ describe('createTeam', () => { ).resolves.toEqualRight(expect.objectContaining(team)); }); - test('rejects for team name length < 6 with TEAM_NAME_INVALID', () => { - const newName = 'smol'; + test('rejects for team name empty with TEAM_NAME_INVALID', () => { + const newName = ''; // Prisma doesn't care mockPrisma.team.create.mockResolvedValue({ diff --git a/packages/hoppscotch-backend/src/team/team.service.ts b/packages/hoppscotch-backend/src/team/team.service.ts index 96d3112e..11ea9613 100644 --- a/packages/hoppscotch-backend/src/team/team.service.ts +++ b/packages/hoppscotch-backend/src/team/team.service.ts @@ -124,7 +124,7 @@ export class TeamService implements UserDataHandler, OnModuleInit { } validateTeamName(title: string): E.Left | E.Right { - if (!title || title.length < 6) return E.left(TEAM_NAME_INVALID); + if (!title || title.trim() === '') return E.left(TEAM_NAME_INVALID); return E.right(true); } diff --git a/packages/hoppscotch-common/locales/en.json b/packages/hoppscotch-common/locales/en.json index e5527b1c..7c4c60cf 100644 --- a/packages/hoppscotch-common/locales/en.json +++ b/packages/hoppscotch-common/locales/en.json @@ -1521,7 +1521,7 @@ "member_role_updated": "User roles updated", "members": "Members", "more_members": "+{count} more", - "name_length_insufficient": "Workspace name should be at least 6 characters long", + "name_length_insufficient": "Workspace name should not be empty", "name_updated": "Workspace name updated", "new": "New Workspace", "new_created": "New workspace created", diff --git a/packages/hoppscotch-common/src/helpers/backend/types/TeamName.ts b/packages/hoppscotch-common/src/helpers/backend/types/TeamName.ts index bbcdb6c0..26182eca 100644 --- a/packages/hoppscotch-common/src/helpers/backend/types/TeamName.ts +++ b/packages/hoppscotch-common/src/helpers/backend/types/TeamName.ts @@ -6,7 +6,7 @@ interface TeamNameBrand { export const TeamNameCodec = t.brand( t.string, - (x): x is t.Branded => x.trim().length >= 6, + (x): x is t.Branded => x.trim() !== "", "TeamName" )