-
Notifications
You must be signed in to change notification settings - Fork 165
Open
Description
Currently the validation of phone number is left to the model fields, but the AbstractShippingAddress
model can't really do phone validation alone, the only thing it can do is to use the PHONENUMBER_DEFAULT_REGION
settings, which is not enough.
Oscar side, with good old forms, they use a PhoneNumberMixin
which does the validation like (simplified):
try:
phone_number = PhoneNumber.from_string(number)
except phonenumbers.NumberParseException:
try:
phone_number = PhoneNumber.from_string(number, region=self.region_code)
if not phone_number.is_valid():
...
Maybe UserAddressSerializer
could have its own phone number validation, making use of the user provided country to give a proper region to the phonenumber_field
library?
Metadata
Metadata
Assignees
Labels
No labels