add phone_validator method#4552
add phone_validator method#4552l3str4nge merged 6 commits intoTheAlgorithms:masterfrom suryapratapsinghsuryavanshi:master
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.
Why only +91 ? It's not very universal. Consider create function for each country.
There was a problem hiding this comment.
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.
All of these comments are redundant. Please remove
There was a problem hiding this comment.
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>
.
|
l3str4nge
left a comment
There was a problem hiding this comment.
Please remove all comments because code is simple
|
Tests are failing |
l3str4nge
left a comment
There was a problem hiding this comment.
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}.