pydantic / pydantic-extra-types

Extra Pydantic types.
MIT License
181 stars 48 forks source link

feature: Improve phone number validator #202

Closed mZbZ closed 1 month ago

mZbZ commented 1 month ago

A number of improvements for the existing phone number type validator

Primarily this change adds logic for the existing variable supported_regions in the validator, this was currently preforming no function at all. If a user supplies a list of two digit phone number regions to the class the validator will now call phonenumbers to check if the parsed number is indeed within one of the regions supplied or else raise a ValidationError. If supported_regions is an empty list (As is now the default), a valid phone number from any region will be accepted.

Additionally, this change:

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (e186814) to head (88a0105). Report is 40 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #202 +/- ## ========================================== Coverage 100.00% 100.00% ========================================== Files 11 17 +6 Lines 685 955 +270 Branches 169 232 +63 ========================================== + Hits 685 955 +270 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.