-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
add phone_validator method #4552
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
add phone_validator method #4552
Conversation
strings/phone_validator.py
Outdated
False | ||
""" | ||
# Created a regex pattern to produce a valid phone number | ||
pat = re.compile(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only +91 ? It's not very universal. Consider create function for each country.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I change this function as a indian_phone_validator.
strings/phone_validator.py
Outdated
if match: | ||
# the match is the same as the phone string it means they are valid phone number. | ||
return match.string == phone | ||
# if match are none so return False. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these comments are redundant. Please remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, i removed them.
I'm back
…On Mon, Jul 19, 2021, 9:30 PM SURYAPRATAP SINGH SURYAVANSHI < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In strings/phone_validator.py
<#4552 (comment)>:
> + >>> phone_validator("01234567896")
+ False
+ >>> phone_validator("919876543218")
+ True
+ >>> phone_validator("+91-1234567899")
+ False
+ """
+ # Created a regex pattern to produce a valid phone number
+ pat = re.compile(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$")
+ # Find their matches
+ match = re.search(pat, phone)
+ # if match are present
+ if match:
+ # the match is the same as the phone string it means they are valid phone number.
+ return match.string == phone
+ # if match are none so return False.
ok, i removed them.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4552 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AU4MCLDPU55PKVNTMFO46JDTYRAIDANCNFSM5AR2IMOQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all comments because code is simple
Tests are failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please take a look at the build and fix the issues
if name == "main":
|
Logs tell you everything! :) |
Please reformat code with |
Thanks, this is my first contribution to the open-source world. |
* add phone_validator method * change the phone_validator to indian_phone_validator * Unnecessary comments removed * all comments deleted * Fixes: #{} new line issue * code reformatted using black
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.