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

Remove old phonenumber validation #4254

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rparke
Copy link
Contributor

@rparke rparke commented Nov 7, 2024

No description provided.

@rparke rparke force-pushed the remove-old-phonenumber-validation branch from 4316277 to 8a40080 Compare November 8, 2024 15:47
Getting formatted phone numbers or international phone information is a repeated pattern so we have created a few utility functions for them to avoid code reuse
@rparke rparke force-pushed the remove-old-phonenumber-validation branch 6 times, most recently from 8a897aa to 5cac882 Compare November 11, 2024 15:48
… validation code

the old validation code was less rigorous in checking if numbers were truly valid. This has meant some actually invalid numbers have made their way into our unit tests. These needed fixing in order for the tests to work properly with the new code
…needs changing to the major version of utils with the correct changes in
@rparke rparke force-pushed the remove-old-phonenumber-validation branch from 5cac882 to afb99ab Compare November 11, 2024 15:50
…ude country code when a flag is passed

In certain situations we don't want to the numbers country code to be pre-pended to the formatted number. A good example is when we are wanting to query the db with the LIKE or ILIKE operators. Formatting with the country code can produce unexpected formatting when searching on a number fragment, so searching is easier if this is just removed.
@rparke rparke force-pushed the remove-old-phonenumber-validation branch from afb99ab to b667a44 Compare November 11, 2024 15:58
Copy link
Contributor

@CrystalPea CrystalPea left a comment

Choose a reason for hiding this comment

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

Looks good to me, will approve when utils commit hash is subbed for a version number.

except InvalidPhoneError as error:
raise ValidationError(f"Invalid phone number: {error.get_legacy_v2_api_error_message()}") from error

@post_load
def format_phone_number(self, item, **kwargs):
item["to"] = validate_and_format_phone_number(item["to"], international=True)
item["to"] = parse_and_format_phone_number(item["to"], international=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

this new function doesn't have international flag, right?

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 this pull request may close these issues.

2 participants