From d3f7308b9ffc66212d19c4f8975736b5796782e7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Thu, 11 Dec 2025 12:39:05 +0530 Subject: [PATCH] fix(validation): disallow whitespace-only team name (#25467) * fix(validation): disallow whitespace-only team name * fix validation at team profile * fix validation for title at event type --------- Co-authored-by: Dhairyashil Shinde <93669429+dhairyashiil@users.noreply.github.com> --- .../teams/components/CreateANewTeamForm.tsx | 1 + .../ee/teams/pages/team-profile-view.tsx | 34 +++++++++++-------- packages/features/eventtypes/lib/types.ts | 2 +- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/packages/features/ee/teams/components/CreateANewTeamForm.tsx b/packages/features/ee/teams/components/CreateANewTeamForm.tsx index 2bd32b810b..097a5950b0 100644 --- a/packages/features/ee/teams/components/CreateANewTeamForm.tsx +++ b/packages/features/ee/teams/components/CreateANewTeamForm.tsx @@ -107,6 +107,7 @@ export const CreateANewTeamForm = (props: CreateANewTeamFormProps) => { defaultValue="" rules={{ required: t("must_enter_team_name"), + validate: (value) => value.trim().length > 0 || t("must_enter_team_name") }} render={({ field: { value } }) => ( <> diff --git a/packages/features/ee/teams/pages/team-profile-view.tsx b/packages/features/ee/teams/pages/team-profile-view.tsx index 84096a44e2..320f7fce4a 100644 --- a/packages/features/ee/teams/pages/team-profile-view.tsx +++ b/packages/features/ee/teams/pages/team-profile-view.tsx @@ -48,20 +48,7 @@ import { revalidateTeamsList } from "@calcom/web/app/(use-page-wrapper)/(main-na const regex = new RegExp("^[a-zA-Z0-9-]*$"); -const teamProfileFormSchema = z.object({ - id: z.number(), - name: z.string(), - slug: z - .string() - .regex(regex, { - message: "Url can only have alphanumeric characters(a-z, 0-9) and hyphen(-) symbol.", - }) - .min(1, { message: "Url cannot be left empty" }), - logo: z.string().nullable(), - bio: z.string(), -}); -type FormValues = z.infer; const SkeletonLoader = () => { return ( @@ -184,7 +171,6 @@ const ProfileView = () => {
@@ -267,6 +253,24 @@ const TeamProfileForm = ({ team, teamId }: TeamProfileFormProps) => { const { t } = useLocale(); const router = useRouter(); + const teamProfileFormSchema = z.object({ + id: z.number(), + name: z + .string() + .trim() + .min(1,t("must_enter_team_name")), + slug: z + .string() + .regex(regex, { + message: "Url can only have alphanumeric characters(a-z, 0-9) and hyphen(-) symbol.", + }) + .min(1, t("team_url_required")), + logo: z.string().nullable(), + bio: z.string(), +}); + +type FormValues = z.infer; + const mutation = trpc.viewer.teams.update.useMutation({ onError: (err) => { showToast(err.message, "error"); @@ -333,7 +337,7 @@ const TeamProfileForm = ({ team, teamId }: TeamProfileFormProps) => { try { await navigator.clipboard.writeText(value); showToast(t("team_id_copied"), "success"); - } catch (error) { + } catch { showToast(t("error_copying_to_clipboard"), "error"); } }; diff --git a/packages/features/eventtypes/lib/types.ts b/packages/features/eventtypes/lib/types.ts index f286236517..b8ffffd365 100644 --- a/packages/features/eventtypes/lib/types.ts +++ b/packages/features/eventtypes/lib/types.ts @@ -262,7 +262,7 @@ const calVideoSettingsSchema = z export const createEventTypeInput = z .object({ - title: z.string().min(1), + title: z.string().trim().min(1), slug: eventTypeSlug, description: z.string().nullish(), length: z.number().int(),