Skip to content

Fix West African mobile money phone number validation regex#242

Merged
matthappens merged 1 commit intomainfrom
claude/fix-xof-phone-pattern-rwLQQ
Mar 3, 2026
Merged

Fix West African mobile money phone number validation regex#242
matthappens merged 1 commit intomainfrom
claude/fix-xof-phone-pattern-rwLQQ

Conversation

@matthappens
Copy link
Contributor

Summary

Updated the phone number validation regex pattern for West African mobile money numbers to enforce country-specific digit requirements instead of a generic range.

Key Changes

  • Senegal (+221): Changed from flexible [0-9]{8,10} to strict [0-9]{9} (9 digits after country code)
  • Ivory Coast (+225): Changed from flexible [0-9]{8,10} to strict [0-9]{10} (10 digits after country code)
  • Benin (+229): Changed from flexible [0-9]{8,10} to strict [0-9]{8,9} (8-9 digits after country code)

Implementation Details

The previous regex pattern ^\+(221|225|229)[0-9]{8,10}$ accepted any combination of 8-10 digits for all three countries, which was too permissive and could allow invalid phone numbers. The updated pattern ^\+(221[0-9]{9}|225[0-9]{10}|229[0-9]{8,9})$ now validates each country code with its correct digit length requirements, improving data quality and reducing invalid number submissions.

https://claude.ai/code/session_01S828qqdXMuJAHkXqNubQxh

The compiled openapi.yaml and mintlify/openapi.yaml contained the
looser pattern ^\+(221|225|229)[0-9]{8,10}$ which incorrectly
accepted wrong digit counts per country. The source file
openapi/components/schemas/common/XofAccountInfo.yaml already had
the correct per-country pattern ^\+(221[0-9]{9}|225[0-9]{10}|229[0-9]{8,9})$.

Ran `make build` to rebundle the spec, syncing both compiled files
with the precise pattern that enforces:
- Senegal (+221): exactly 9 digits
- Ivory Coast (+225): exactly 10 digits
- Benin (+229): 8 or 9 digits

https://claude.ai/code/session_01S828qqdXMuJAHkXqNubQxh
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

✱ Stainless preview builds

This PR will update the grid SDKs with the following commit messages.

kotlin

chore(internal): regenerate SDK with no functional changes

openapi

fix(types): correct phone number pattern validation for West African mobile money

python

chore(internal): regenerate SDK with no functional changes

typescript

chore(internal): regenerate SDK with no functional changes
grid-openapi studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅

grid-python studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ✅lint ✅test ✅

pip install https://pkg.stainless.com/s/grid-python/ec2ad2be0586afbef0eb6f51cdc301da98f5f7cf/grid-0.0.1-py3-none-any.whl
⚠️ grid-kotlin studio · code

Your SDK build had a failure in the build CI job, which is a regression from the base state.
generate ✅build ❗lint ✅test ❗

grid-typescript studio · code

Your SDK build had at least one "note" diagnostic.
generate ✅build ✅lint ✅test ✅

npm install https://pkg.stainless.com/s/grid-typescript/6e4b70e1f8409c395e0e4e522bef16e80fbaf21a/dist.tar.gz

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-03-03 18:45:48 UTC

@matthappens matthappens marked this pull request as ready for review March 3, 2026 18:32
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 3, 2026

Greptile Summary

This PR tightens the West African mobile money phone number validation regex in both openapi.yaml and mintlify/openapi.yaml, replacing a single permissive range with per-country digit length requirements.

  • Senegal (+221): Changed from [0-9]{8,10} to [0-9]{9} — correctly enforces 9 local digits (e.g., 77 XXX XX XX).
  • Ivory Coast (+225): Changed from [0-9]{8,10} to [0-9]{10} — correctly reflects the post-2021 10-digit format (after the national renumbering expanded from 8 to 10 digits).
  • Benin (+229): Changed from [0-9]{8,10} to [0-9]{8,9} — the range is intentional to accommodate both the legacy 8-digit format and the newer 9-digit format introduced in 2023.
  • Both openapi.yaml and mintlify/openapi.yaml are updated identically and kept in sync.
  • The provided example (+221781234567) continues to satisfy the new regex.
  • Note: this is a validation-tightening breaking change — API clients sending numbers that matched the old (more permissive) regex but fall outside the new per-country ranges will now receive validation errors. This appears intentional per the PR description.

Confidence Score: 5/5

  • This PR is safe to merge; the regex correctly enforces real-world digit requirements for each country and both spec files are kept in sync.
  • The change is a small, targeted regex update in two YAML spec files with no logic or code changes. The new patterns correctly reflect documented national numbering plans (9 digits for Senegal, 10 for Ivory Coast post-2021, 8-9 for Benin during its transition). Both files are updated identically. The only consideration is that this intentionally tightens validation, which is the stated goal of the PR.
  • No files require special attention.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Phone Number Input] --> B{Matches regex?}
    B -->|No| C[Validation Error]
    B -->|Yes| D{Country Code?}
    D -->|221| E["Senegal: exactly 9 local digits"]
    D -->|225| F["Ivory Coast: exactly 10 local digits"]
    D -->|229| G["Benin: 8 or 9 local digits"]
    E --> H[Valid - Accepted]
    F --> H
    G --> H
Loading

Last reviewed commit: ef364a2

@matthappens matthappens merged commit 8ea34aa into main Mar 3, 2026
5 of 6 checks passed
@matthappens matthappens deleted the claude/fix-xof-phone-pattern-rwLQQ branch March 3, 2026 18:40
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.

3 participants