Skip to content

fix(BJ): update Benin phone number to 10-digit format (post-Nov 2024 migration) - #778

Open
urooj-bits wants to merge 1 commit into
razorpay:masterfrom
urooj-bits:fix/bj-phone-number-10-digit
Open

urooj-bits wants to merge 1 commit into
razorpay:masterfrom
urooj-bits:fix/bj-phone-number-10-digit

Conversation

@urooj-bits

Copy link
Copy Markdown

Description

Fixes #777

On 30 November 2024, Benin (+229) migrated all national fixed-line and mobile numbers from 8 digits to 10 digits by prepending 01 to all existing numbers. The BJ entry in data.json still carries the pre-migration 8-digit pattern, causing all current Benin numbers to fail isValidPhoneNumber and be mis-parsed by parsePhoneNumber/formatPhoneNumber.

Changes Made

Title ---
Fixes Issue #777
JIRA link NA
Slack thread NA
  • Updated BJ.regex from [24-689]\d{7} → 01\d{8} (10-digit national format, all numbers now start with 01)
  • Updated BJ.format from xx xx xx xx → xx xx xx xx xx (5 groups of 2 for 10 digits)

Source: Google's libphonenumber PhoneNumberMetadata.xml — the authoritative source documented in i18nify-data/phone-number/README.md. The BJ territory entry defines nationalNumberPattern as 01\d{8} and format pattern as $1 $2 $3 $4 $5.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Per the repro script in #777, after this change:

  • isValidPhoneNumber("+2290195123456", "BJ") → true

  • isValidPhoneNumber("0195123456", "BJ") → true

  • parsePhoneNumber("+2290195123456", "BJ") → correct dialCode: "+229", phoneNumber: "0195123456", formattedPhoneNumber: "+229 01 95 12 34 56"

  • Is your change backward compatible? Yes — the old 8-digit format is no longer issued in Benin's national plan.

Checklist

  • I have performed a self-review of my code
  • My changes are sourced from the documented authoritative source (libphonenumber PhoneNumberMetadata.xml)
  • My commit messages are clear and follow the project's commit message conventions
  • Reviewer added (SLA 2 days)

This branch has not been deployed

No deployments
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.

Benin (BJ) 10-digit phone numbers (01XXXXXXXX) are rejected and mis-parsed

1 participant