Skip to content

Commit

Permalink
Update phone number validation rules
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kasperbirch1 committed Oct 13, 2023
1 parent 700648b commit f00b79c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/apps/patron-page/PatronPage.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 be comprised solely of numbers or begin with a +",
control: { type: "text" }
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/contact-info-section/ContactInfoPhone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const ContactInfoPhone: FC<ContactInfoPhoneProps> = ({
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")
Expand Down

0 comments on commit f00b79c

Please sign in to comment.