diff --git a/utils/__init__.py b/utils/__init__.py index 9f4d9d7..c1a3a3a 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,2 +1,3 @@ from .createDf import createDf -from .vcfGenerator import generateVcard,generateVcf \ No newline at end of file +from .vcfGenerator import generateVcard,generateVcf +from .validateNumbers import validatePhoneNumber \ No newline at end of file diff --git a/utils/validateNumbers.py b/utils/validateNumbers.py index af41d1d..b29c310 100644 --- a/utils/validateNumbers.py +++ b/utils/validateNumbers.py @@ -1,8 +1,8 @@ -# import phonenumbers +import phonenumbers -# def validatePhoneNumber(number): -# try: -# parsedNumber = phonenumbers.parse(number) -# return phonenumbers.is_valid_number(parsedNumber) -# except phonenumbers.phonenumberutil.NumberParseException as e: -# return False \ No newline at end of file +def validatePhoneNumber(number): + try: + parsedNumber = phonenumbers.parse(number) + return phonenumbers.is_valid_number(parsedNumber) + except phonenumbers.phonenumberutil.NumberParseException as e: + return False \ No newline at end of file diff --git a/utils/vcfGenerator.py b/utils/vcfGenerator.py index ff4cf9c..5890ac2 100644 --- a/utils/vcfGenerator.py +++ b/utils/vcfGenerator.py @@ -23,7 +23,7 @@ def generateVcard(row, headers, vCards): family=row.get(headers.get("Last Name",""),""), given=row.get(headers.get("First Name",""),""), additional=row.get(headers.get("Middle Name",""),""), - suffix=request.form.get("Suffix","")+" "+str(row.name+1) if request.form.get("autoIncrement","") == "true" else request.form.get("Prefix",""), + suffix=request.form.get("Suffix","")+" "+str(row.name+1) if request.form.get("autoIncrement","") == "true" else request.form.get("Suffix",""), prefix=request.form.get("Prefix","") ) @@ -33,7 +33,7 @@ def generateVcard(row, headers, vCards): fields = fields.split(",") if fields else [] for field in fields: phone = row.get(field,"") - if phone and phone.isnumeric(): + if phone: telephone = vcard.add("tel") telephone.type_param = ["HOME"] telephone.value = phone