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 phone number types #25

Merged
merged 13 commits into from
Apr 10, 2023
Merged

Add phone number types #25

merged 13 commits into from
Apr 10, 2023

Conversation

JamesHutchison
Copy link
Contributor

@JamesHutchison JamesHutchison commented Apr 9, 2023

This introduces a generic international phone number and a phone number type that defaults to the US. The default format includes extensions.

Feel free to comment heavily.

Addresses:

pydantic/pydantic#1551 - phone number type, which quite a lot of attention

From pydantic/pydantic#5012

@JamesHutchison JamesHutchison changed the title Add Phone number types Add phone number types Apr 9, 2023
@JamesHutchison
Copy link
Contributor Author

I'm out of time. Will look at the issues caught by the CI later

@yezz123 yezz123 self-requested a review April 9, 2023 07:42
@yezz123 yezz123 added the Types label Apr 9, 2023
@yezz123
Copy link
Collaborator

yezz123 commented Apr 9, 2023

Hello @JamesHutchison you can rebase this, and its will work!

I will give it a review!

Copy link
Collaborator

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have more tests for other countries that would be super cool!

Otherwise LGTM 👍🏻

pydantic_extra_types/types/phone_numbers.py Outdated Show resolved Hide resolved
@JamesHutchison JamesHutchison requested a review from yezz123 April 10, 2023 01:01
@yezz123 yezz123 enabled auto-merge (squash) April 10, 2023 19:02
@yezz123 yezz123 merged commit 215c735 into pydantic:main Apr 10, 2023
@yezz123
Copy link
Collaborator

yezz123 commented Apr 10, 2023

I add some changes! and test it locally its works fine!

Thank you @JamesHutchison

@@ -2,22 +2,18 @@

from typing import Any, Callable, Generator

import phonenumbers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes phonenumbers a requirement. This is probably fine as it isn't the biggest library, however the ImportError try block no longer makes sense below.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks it was an issue 👍🏻

@JamesHutchison 🙏🏻

@asaah18
Copy link

asaah18 commented Apr 26, 2023

Just to make sure, is the default format E.164 standard?
As in, +9665xxxxxxxxwhere 966 is the country code?

@JamesHutchison
Copy link
Contributor Author

The default format is RFC3966 which supports extensions

@nameer
Copy link

nameer commented Sep 28, 2023

How to set the default region code or the format type while using PhoneNumber in a model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants