Skip to content

feat: add international phone number support#93

Merged
joaquimds merged 4 commits into
masterfrom
feat/international-phone-numbers
May 7, 2026
Merged

feat: add international phone number support#93
joaquimds merged 4 commits into
masterfrom
feat/international-phone-numbers

Conversation

@joaquimds
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional international phone number validation to the Join Flow, gated behind a new WordPress setting and using google-libphonenumber for region-aware checks.

Changes:

  • Add google-libphonenumber-based validation for phoneNumber, using addressCountry when available and requiring international format when it isn’t.
  • Add a new WP setting (enable_international_phone_numbers) and expose it to the frontend env payload.
  • Prevent address fields from being required in the schema when the address section is hidden.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
packages/join-flow/src/schema.ts Adds libphonenumber validation + adjusts address-required logic based on HIDE_ADDRESS.
packages/join-flow/package.json Adds google-libphonenumber dependency and TypeScript types.
packages/join-block/src/Settings.php Adds admin setting to enable international phone validation (help text needs alignment).
packages/join-block/src/Blocks.php Exposes ENABLE_INTERNATIONAL_PHONE_NUMBERS to the Join Flow frontend env JSON.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +183 to +185
phoneNumber: Boolean(getEnv("ENABLE_INTERNATIONAL_PHONE_NUMBERS"))
? string().when("addressCountry", (country: string, schema) => {
const required = Boolean(getEnv("REQUIRE_PHONE_NUMBER"));
Comment on lines +186 to +195
const message = country
? "Please enter a valid phone number"
: "Please enter a valid phone number, including the country code (e.g. +44...)";
const test = schema.test(
"is-valid-phone",
message,
(value: string | undefined) => isValidInternationalPhone(value, country)
);
return required ? test.required("Phone number is required") : test;
})
Comment thread packages/join-block/src/Settings.php Outdated
Comment on lines +64 to +66
'When enabled, phone numbers are validated against the country selected in the address. ' .
'If the address section is hidden, members must enter a number in international format ' .
'(e.g. +44...). Otherwise, only UK numbers are accepted.'
Comment on lines 21 to 25
"bootstrap": "^4.5.2",
"css-loader": "^6.8.1",
"date-fns": "^2.16.1",
"google-libphonenumber": "^3.2.33",
"dotenv": "^8.2.0",
@joaquimds joaquimds force-pushed the feat/international-phone-numbers branch from 4b34bfb to d7feded Compare May 7, 2026 17:28
@joaquimds joaquimds force-pushed the feat/international-phone-numbers branch from d7feded to fa8f6ee Compare May 7, 2026 17:29
@joaquimds joaquimds requested a review from Copilot May 7, 2026 17:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 6 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • packages/join-flow/package-lock.json: Language not supported

Comment on lines +172 to +174
phoneNumber: Boolean(getEnv("ENABLE_INTERNATIONAL_PHONE_NUMBERS"))
? string().when("addressCountry", (country: string, schema) => {
const required = Boolean(getEnv("REQUIRE_PHONE_NUMBER"));
Comment on lines +22 to +23
try {
const parsed = phoneUtil.parse(value, country || undefined);
Comment on lines +172 to 197
phoneNumber: Boolean(getEnv("ENABLE_INTERNATIONAL_PHONE_NUMBERS"))
? string().when("addressCountry", (country: string, schema) => {
const required = Boolean(getEnv("REQUIRE_PHONE_NUMBER"));
const message = country
? "Please enter a valid phone number"
: "Please enter a valid phone number, including the country code (e.g. +44...)";
const test = schema.test(
"is-valid-phone",
message,
(value: string | undefined) => isValidInternationalPhone(value, country)
);
return required ? test.required("Phone number is required") : test;
})
: Boolean(getEnv("REQUIRE_PHONE_NUMBER"))
? string()
.phone("GB", false, "A valid UK phone number is required")
.required()
.test(
"is-valid-phone",
"A valid UK phone number is required",
(value) => isValidInternationalPhone(value, "GB")
)
.required("Phone number is required")
: string().test(
// .test() used because .phone() forces .required()
"is-valid-phone",
"Please enter a valid UK phone number",
(value) => !value || string().phone("GB", false).isValidSync(value)
(value) => isValidInternationalPhone(value, "GB")
),
Comment thread packages/join-flow/package.json Outdated
Comment thread packages/join-block/src/Settings.php Outdated
joaquimds and others added 3 commits May 7, 2026 19:35
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@joaquimds joaquimds merged commit 3656aa0 into master May 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants