From e6a043ae6b37e5239a71c9590f17ecc8d4390570 Mon Sep 17 00:00:00 2001 From: Kasper Birch Date: Thu, 12 Oct 2023 15:13:17 +0200 Subject: [PATCH] Update phone number validation rules Ensure phone numbers are 6-15 characters in length and either numeric or start with a '+' This is to ensure that we can accept numbers from various sources while safeguarding against sending a number to the API that might cause an error. --- src/apps/patron-page/PatronPage.dev.tsx | 3 ++- src/components/contact-info-section/ContactInfoPhone.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apps/patron-page/PatronPage.dev.tsx b/src/apps/patron-page/PatronPage.dev.tsx index 309f3964c1..03812aa98f 100644 --- a/src/apps/patron-page/PatronPage.dev.tsx +++ b/src/apps/patron-page/PatronPage.dev.tsx @@ -241,8 +241,9 @@ export default { control: { type: "text" } }, phoneInputMessageText: { + name: "Phone input validation message", defaultValue: - "The phone number should be from Denmark (+45), Germany (+49), or Greenland (+299)", + "The phone number must be 6 to 15 characters in length and should either be comprised solely of numbers or begin with a +", control: { type: "text" } } } diff --git a/src/components/contact-info-section/ContactInfoPhone.tsx b/src/components/contact-info-section/ContactInfoPhone.tsx index e586cf5a17..e8e8aed13e 100644 --- a/src/components/contact-info-section/ContactInfoPhone.tsx +++ b/src/components/contact-info-section/ContactInfoPhone.tsx @@ -29,7 +29,7 @@ const ContactInfoPhone: FC = ({ id="phone-input" required={isRequired} type="tel" - pattern="(\+45|0045)[0-9]{8}|(\+49|0049)[0-9]{7,11}|(\+299|00299)[0-9]{6}" + pattern="\+?[0-9]{6,15}" title={t("phoneInputMessageText")} onChange={(newPhoneNumber) => changePatron(newPhoneNumber, "phoneNumber")