From c50c432782ed596504bd1ce1586fec569519879b Mon Sep 17 00:00:00 2001 From: andrey-canon Date: Tue, 16 Jul 2024 16:23:27 -0500 Subject: [PATCH] chore: update PhonenumberSerializer docstring --- .../djangoapps/user_api/accounts/serializers.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/user_api/accounts/serializers.py b/openedx/core/djangoapps/user_api/accounts/serializers.py index a3aced755193..d23330742fba 100644 --- a/openedx/core/djangoapps/user_api/accounts/serializers.py +++ b/openedx/core/djangoapps/user_api/accounts/serializers.py @@ -48,11 +48,23 @@ class PhoneNumberSerializer(serializers.BaseSerializer): # lint-amnesty, pylint: disable=abstract-method """ - Class to serialize phone number into a digit only representation + Class to serialize phone number into a digit only representation. + + This serializer removes all non-numeric characters from the phone number, + allowing '+' only at the beginning of the number. """ def to_internal_value(self, data): - """Remove all non numeric characters in phone number""" + """ + Remove all non-numeric characters from the phone number. + + Args: + data (str): The input phone number string. + + Returns: + str or None: The cleaned phone number string containing only digits, + with an optional '+' at the beginning. + """ return re.sub(r'(?!^)\+|[^0-9+]', "", data) or None