Skip to content

Commit

Permalink
Task: Remove Incorrect Warnings #384 (#392)
Browse files Browse the repository at this point in the history
* Checking for empty values in phone numbers and emails to avoid flagging them with an incorrect warning

* Correcting statement checking for empty values
  • Loading branch information
JulianForeman authored Sep 25, 2024
1 parent 78a8e20 commit 900524f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion django/api/services/spreadsheet_uploader_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ def validate_phone_numbers(df, *columns, **kwargs):
series = df[column]
for index, phone_number in series.items():
formatted_number = str(phone_number).strip().replace('-', '')
if formatted_number == '' or len(formatted_number) != 10 or int(formatted_number[:3]) not in AREA_CODES:
if len(formatted_number) != 10 or int(formatted_number[:3]) not in AREA_CODES:
if pd.isna(formatted_number) or formatted_number == '':
continue
indices.append(index + kwargs.get("indices_offset", 0))
if indices:
result[column] = {
Expand Down Expand Up @@ -302,6 +304,8 @@ def email_validator(df, *columns, **kwargs):
try:
validate_email(value, dns_resolver=resolver)
except EmailNotValidError:
if pd.isna(value) or value == '':
continue
indices.append(index + kwargs.get("indices_offset", 0))
if indices:
result[column] = {
Expand Down

0 comments on commit 900524f

Please sign in to comment.