Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhoneNumber scalar is not fully compatible with E.164 format #2709

Closed
2 of 4 tasks
dsengupta-mdsol opened this issue Jan 24, 2025 · 6 comments
Closed
2 of 4 tasks

PhoneNumber scalar is not fully compatible with E.164 format #2709

dsengupta-mdsol opened this issue Jan 24, 2025 · 6 comments

Comments

@dsengupta-mdsol
Copy link

dsengupta-mdsol commented Jan 24, 2025

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Scalars package version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug
Currently the regex in use for the PhoneNumber scalar is PHONE_NUMBER_REGEX = /^\+[1-9]\d{6,14}$/;. Which seems incorrect. This will not allow extensions which can be 7 numeric long, even E.164 supports this, scalar will invalidate the number.

To Reproduce Steps to reproduce the behavior:

Enter a phone number as +4420794609581234 and it will get invalidated.

Expected behavior

Not Wikipedia should NOT be the source of truth for this validation. Rather, there is a portal to validate E.164 format which explains the parts of E.164 numbers, matching criteria and also gives you a regular expression which is ^\+?\d{1,3}(\-|\x20)?\(?\d+\)?((\-|\x20)?\d+)+$

Environment:

  • OS: MacOs
  • GraphQL Scalars Version: Latest
  • NodeJS: 18
@ardatan
Copy link
Collaborator

ardatan commented Jan 24, 2025

Thanks for the issue!
Would you create a PR to update the regexp?

@nthombare-mdsol
Copy link
Contributor

I will update and raise the PR for the same. @ardatan

@nthombare-mdsol
Copy link
Contributor

Hello @ardatan I have raised PR and also addressed test cases. Could you please look into it?

@nthombare-mdsol
Copy link
Contributor

Hi @ardatan, do you have a timeline for when this will be released in the new version? We're using your library, and once the new version with these changes is out, we'll update our package accordingly.

@ardatan
Copy link
Collaborator

ardatan commented Jan 29, 2025

Thanks all! Now it has been released!

@ardatan ardatan closed this as completed Jan 29, 2025
@nthombare-mdsol
Copy link
Contributor

Thanks, @ardatan! We've updated to the latest version, and everything is working smoothly now. I appreciate your quick response, the merge, and the opportunity to contribute to this repo! 🤝

cc: @dsengupta-mdsol

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

No branches or pull requests

3 participants