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

Add E.164 format validation for strings #3476

Merged
merged 5 commits into from
May 16, 2024
Merged

Conversation

maurer2
Copy link

@maurer2 maurer2 commented May 8, 2024

Hello, following the previous discussion, I added validation for the E.164 format on strings using a modified regex from this article. I removed support for spaces as those don't seem to be permitted. The validation could be further enhanced by prohibiting 0 as the first value since country codes start with 1.

There is an alternative regular expression from the Twilio docs for E.164 numbers. This regular expression permits very short E.164 numbers. It could be used in tandem with the existing string validations like min and max. This would give users the option to adapt the number length further, which seems to be necessary in some instances, according to this stack overflow post.

Cheers

Thank you for your contribution to our project! Before submitting your pull request, please ensure the following:

  • Your code changes are well-documented.
  • You have tested your changes.
  • You have updated any relevant documentation.

Copy link

netlify bot commented May 8, 2024

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
🔨 Latest commit 55290ee
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/66458d3f4917e80007bb1a13
😎 Deploy Preview https://deploy-preview-3476--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@colinhacks
Copy link
Owner

This seems good to me. Is there a specific reason this is still a draft PR? My plan is to merge this into v4. String validations like uuid, etc are going to be handled quite differently in Zod 4 but I'm happy to merge this as a starting point before I start the refactor.

@maurer2 maurer2 marked this pull request as ready for review May 11, 2024 01:52
@maurer2
Copy link
Author

maurer2 commented May 11, 2024

Hello, apologies for the delay. I first needed to further investigate in order to be able to add the pr description.

Cheers

@colinhacks colinhacks changed the base branch from master to v4 May 14, 2024 20:43
@maurer2
Copy link
Author

maurer2 commented May 15, 2024

Hello, added a section on E.164 to both Readme files.

@colinhacks colinhacks changed the base branch from v4 to master May 16, 2024 04:36
@colinhacks colinhacks changed the base branch from master to v4 May 16, 2024 04:36
@colinhacks colinhacks merged commit 31a4418 into colinhacks:v4 May 16, 2024
3 of 4 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.

None yet

2 participants