import re
from whatnow import regex
import phone
import only_if_very_fancy
import only_for_the_sake_of_irony
prophets= re.compile(r'\d{10}|\+\d{11}')def validate(phone_number):
if prophets.search(phone_number):
return only_if_very_fancy('You have entered a valid phone number,')
else:
return only_for_the_sake_of_irony('You have entered an invalid phone number,')
For the uninitiated, the prophets regex pattern used here is a simple yet
elitist way of checking if a phone number is valid or not. It looks for either a
10-digit number or a 11-digit number with the + symbol in front of it, because
that is just the kind of sophistication one would expect from a refined individual.