Scheduling infrastructure for absolutely everyone.
fix(validation): disallow whitespace-only team name (#25467)
Abhishekd3f7308b9ffc
diff --git a/packages/features/ee/teams/components/CreateANewTeamForm.tsx b/packages/features/ee/teams/components/CreateANewTeamForm.tsxindex 2bd32b810b6..097a5950b02 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.tsxindex 84096a44e20..320f7fce4a1 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-naconst 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<typeof teamProfileFormSchema>;const SkeletonLoader = () => {return (@@ -184,7 +171,6 @@ const ProfileView = () => {<Label className="text-emphasis mt-5">{t("about")}</Label><divclassName=" text-subtle wrap-break-word text-sm [&_a]:text-blue-500 [&_a]:underline [&_a]:hover:text-blue-600"- // eslint-disable-next-line react/no-dangerdangerouslySetInnerHTML={{ __html: markdownToSafeHTML(team.bio ?? null) }}/></>@@ -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<typeof teamProfileFormSchema>;+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.tsindex f2862365177..b8ffffd3656 100644--- a/packages/features/eventtypes/lib/types.ts+++ b/packages/features/eventtypes/lib/types.ts@@ -262,7 +262,7 @@ const calVideoSettingsSchema = zexport 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(),