zod
zod copied to clipboard
Add E.164 format validation for strings
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:
- [x] Your code changes are well-documented.
- [x] You have tested your changes.
- [ ] You have updated any relevant documentation.
Deploy Preview for guileless-rolypoly-866f8a ready!
Name | Link |
---|---|
Latest commit | 55290ee1b079b33a0dff2f919f0cd31d63cb36b3 |
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...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
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.
Hello, apologies for the delay. I first needed to further investigate in order to be able to add the pr description.
Cheers
Hello, added a section on E.164 to both Readme files.