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

serializerfields.PhoneNumberField not validating int number correctly #265

Closed
dionysio opened this issue Feb 19, 2019 · 2 comments · Fixed by #523
Closed

serializerfields.PhoneNumberField not validating int number correctly #265

dionysio opened this issue Feb 19, 2019 · 2 comments · Fixed by #523

Comments

@dionysio
Copy link

I have a serializer:

class MySerializer(Serializer):
    phone = PhoneNumberField(required=True)

and in my view:

serializer = MySerializer(data=request.data)
if serializer.is_valid():
    phone = serializer.validated_data['phone'].as_e164

This doesn't work if I pass phone=15417543010 (int number). In that case, it passes validation, but serializer.validated_data['phone'] will be None.

@dionysio
Copy link
Author

yep, it works fine with strings

@Alig1493
Copy link

Alig1493 commented Feb 4, 2020

the phonenumber filed here according to the to_python logic here should raise a type error in case it is unable to parse and give back results. It checks for the phone number of type str and phonenumber type instance for now. I can take a look at this further and f course I might be missing valuable context in my insight.

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 a pull request may close this issue.

2 participants