From 0ea743088b666e650ba5d0106a2dc9ab1836ab0d Mon Sep 17 00:00:00 2001 From: Nadav Nir Date: Fri, 22 May 2026 16:32:17 +0200 Subject: [PATCH 1/2] fix: remove +49 phone number format restriction from all contact detail forms Phone fields in volunteer, opportunity, and agent contact detail sections required a leading '+' (PHONE_NUMBER_REGEX = /^\+[0-9\s]+$/). Accept any non-empty string instead so coordinators can enter numbers in any format. Co-Authored-By: Claude Sonnet 4.6 --- .../ContactDetails/agent/agentContactDetailsSchema.ts | 6 ++---- .../opportunity/opportunityContactDetailsSchema.ts | 4 +--- .../volunteer/volunteerContactDetailsSchema.ts | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts index bb58c2b1..e4a8de39 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts @@ -1,4 +1,4 @@ -import { AgentRoles, PHONE_NUMBER_REGEX } from "@/config/constants"; +import { AgentRoles } from "@/config/constants"; import { z } from "zod"; export const createAgentContactDetailsSchema = (t: (key: string) => string) => { @@ -16,11 +16,9 @@ export const createAgentContactDetailsSchema = (t: (key: string) => string) => { .min(1, t("dashboard.agentProfile.contactDetails.validation.emailRequired")), phone: z .string() - .min(1, t("dashboard.agentProfile.contactDetails.validation.mobileRequired")) - .regex(PHONE_NUMBER_REGEX, t("dashboard.agentProfile.contactDetails.validation.mobileInvalid")), + .min(1, t("dashboard.agentProfile.contactDetails.validation.mobileRequired")), landline: z .string() - .regex(PHONE_NUMBER_REGEX, t("dashboard.agentProfile.contactDetails.validation.landlineInvalid")) .optional() .or(z.literal("")), address: z.string().optional().or(z.literal("")), diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts index 9f7c4383..3bbbded3 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts @@ -1,4 +1,3 @@ -import { PHONE_NUMBER_REGEX } from "@/config/constants"; import { z } from "zod"; export const createOpportunityContactDetailsSchema = (t: (key: string) => string) => { @@ -6,8 +5,7 @@ export const createOpportunityContactDetailsSchema = (t: (key: string) => string name: z.string().min(1, t("dashboard.opportunityProfile.contactDetails.validation.nameRequired")), phone: z .string() - .min(1, t("dashboard.opportunityProfile.contactDetails.validation.phoneRequired")) - .regex(PHONE_NUMBER_REGEX, t("dashboard.opportunityProfile.contactDetails.validation.phoneInvalid")), + .min(1, t("dashboard.opportunityProfile.contactDetails.validation.phoneRequired")), email: z .string() .min(1, t("dashboard.opportunityProfile.contactDetails.validation.emailRequired")) diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts index e31fdbf8..d9721460 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts @@ -1,4 +1,3 @@ -import { PHONE_NUMBER_REGEX } from "@/config/constants"; import { VolunteerCommunicationType } from "need4deed-sdk"; import { z } from "zod"; @@ -6,8 +5,7 @@ export const createVolunteerContactDetailsSchema = (t: (key: string) => string) return z.object({ phone: z .string() - .min(1, t("dashboard.volunteerProfile.contactDetails.validation.phoneRequired")) - .regex(PHONE_NUMBER_REGEX, t("dashboard.volunteerProfile.contactDetails.validation.phoneInvalid")), + .min(1, t("dashboard.volunteerProfile.contactDetails.validation.phoneRequired")), email: z .string() .min(1, t("dashboard.volunteerProfile.contactDetails.validation.emailRequired")) From acfe80bdfc9105bb1d6ab1c94ebcdac42e1faf33 Mon Sep 17 00:00:00 2001 From: Nadav Nir Date: Fri, 22 May 2026 16:36:41 +0200 Subject: [PATCH 2/2] fix: allow all phone formats, reject non-digit characters Replace strict /^\+[0-9\s]+$/ with /^[+\d\s\-()/]+$/ so numbers like 0160 123 456 or (030) 123-456 are accepted, while letters and arbitrary text are still rejected. Co-Authored-By: Claude Sonnet 4.6 --- .../ContactDetails/agent/agentContactDetailsSchema.ts | 6 ++++-- .../opportunity/opportunityContactDetailsSchema.ts | 4 +++- .../volunteer/volunteerContactDetailsSchema.ts | 4 +++- src/config/constants.ts | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts index e4a8de39..bb58c2b1 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/agent/agentContactDetailsSchema.ts @@ -1,4 +1,4 @@ -import { AgentRoles } from "@/config/constants"; +import { AgentRoles, PHONE_NUMBER_REGEX } from "@/config/constants"; import { z } from "zod"; export const createAgentContactDetailsSchema = (t: (key: string) => string) => { @@ -16,9 +16,11 @@ export const createAgentContactDetailsSchema = (t: (key: string) => string) => { .min(1, t("dashboard.agentProfile.contactDetails.validation.emailRequired")), phone: z .string() - .min(1, t("dashboard.agentProfile.contactDetails.validation.mobileRequired")), + .min(1, t("dashboard.agentProfile.contactDetails.validation.mobileRequired")) + .regex(PHONE_NUMBER_REGEX, t("dashboard.agentProfile.contactDetails.validation.mobileInvalid")), landline: z .string() + .regex(PHONE_NUMBER_REGEX, t("dashboard.agentProfile.contactDetails.validation.landlineInvalid")) .optional() .or(z.literal("")), address: z.string().optional().or(z.literal("")), diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts index 3bbbded3..9f7c4383 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/opportunity/opportunityContactDetailsSchema.ts @@ -1,3 +1,4 @@ +import { PHONE_NUMBER_REGEX } from "@/config/constants"; import { z } from "zod"; export const createOpportunityContactDetailsSchema = (t: (key: string) => string) => { @@ -5,7 +6,8 @@ export const createOpportunityContactDetailsSchema = (t: (key: string) => string name: z.string().min(1, t("dashboard.opportunityProfile.contactDetails.validation.nameRequired")), phone: z .string() - .min(1, t("dashboard.opportunityProfile.contactDetails.validation.phoneRequired")), + .min(1, t("dashboard.opportunityProfile.contactDetails.validation.phoneRequired")) + .regex(PHONE_NUMBER_REGEX, t("dashboard.opportunityProfile.contactDetails.validation.phoneInvalid")), email: z .string() .min(1, t("dashboard.opportunityProfile.contactDetails.validation.emailRequired")) diff --git a/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts b/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts index d9721460..e31fdbf8 100644 --- a/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts +++ b/src/components/Dashboard/Profile/sections/ContactDetails/volunteer/volunteerContactDetailsSchema.ts @@ -1,3 +1,4 @@ +import { PHONE_NUMBER_REGEX } from "@/config/constants"; import { VolunteerCommunicationType } from "need4deed-sdk"; import { z } from "zod"; @@ -5,7 +6,8 @@ export const createVolunteerContactDetailsSchema = (t: (key: string) => string) return z.object({ phone: z .string() - .min(1, t("dashboard.volunteerProfile.contactDetails.validation.phoneRequired")), + .min(1, t("dashboard.volunteerProfile.contactDetails.validation.phoneRequired")) + .regex(PHONE_NUMBER_REGEX, t("dashboard.volunteerProfile.contactDetails.validation.phoneInvalid")), email: z .string() .min(1, t("dashboard.volunteerProfile.contactDetails.validation.emailRequired")) diff --git a/src/config/constants.ts b/src/config/constants.ts index 98aa2046..330e7626 100644 --- a/src/config/constants.ts +++ b/src/config/constants.ts @@ -72,6 +72,6 @@ export const EMPTY_PLACEHOLDER_VALUE = "–"; export const MAX_DESCRIPTION_LENGTH = 500; -export const PHONE_NUMBER_REGEX = /^\+[0-9\s]+$/; +export const PHONE_NUMBER_REGEX = /^[+\d\s\-()/]+$/; export const LOGGED_IN_COOKIE = "is_logged_in=true; path=/; max-age=6000; SameSite=Lax; Secure";