Skip to content

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

Merged
merged 6 commits into from
Jul 20, 2021
Merged

add phone_validator method #4552

merged 6 commits into from
Jul 20, 2021

Conversation

suryapratapsinghsuryavanshi
Copy link
Contributor

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added the awaiting reviews This PR is ready to be reviewed label Jul 18, 2021
False
"""
# Created a regex pattern to produce a valid phone number
pat = re.compile(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$")
Copy link
Member

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.

Copy link
Contributor Author

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.

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.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i removed them.

@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Jul 19, 2021
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Jul 19, 2021
@ASHIKSAR
Copy link

ASHIKSAR commented Jul 19, 2021 via email

Copy link
Member

@l3str4nge l3str4nge left a 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

@ghost ghost added awaiting changes A maintainer has requested changes to this PR tests are failing Do not merge until tests pass and removed awaiting reviews This PR is ready to be reviewed labels Jul 19, 2021
@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Jul 19, 2021
@l3str4nge
Copy link
Member

Tests are failing

Copy link
Member

@l3str4nge l3str4nge left a 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

@ghost ghost added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Jul 20, 2021
@suryapratapsinghsuryavanshi
Copy link
Contributor Author

if name == "main":

  • print(f'{indian_phone_validator("+918827897895")}\n')
    \ No newline at end of file
  • print(f'{indian_phone_validator("+918827897895")}\n')
    would reformat strings/indian_phone_validator.py
    Oh no! 💥 💔 💥
    1 file would be reformatted, 917 files would be left unchanged.

How can I solve this problem

@l3str4nge
Copy link
Member

Logs tell you everything! :) No newline at end of file

@ghost ghost added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Jul 20, 2021
@l3str4nge
Copy link
Member

Please reformat code with black

@ghost ghost removed the tests are failing Do not merge until tests pass label Jul 20, 2021
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Jul 20, 2021
@l3str4nge l3str4nge merged commit 72aa4cc into TheAlgorithms:master Jul 20, 2021
@suryapratapsinghsuryavanshi
Copy link
Contributor Author

Thanks, this is my first contribution to the open-source world.

shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants