validatorjs / validator.js

String validation
MIT License
23.01k stars 2.29k forks source link

Mobile Phone validations - For The First Time Contributors #1761

Open ezkemboi opened 2 years ago

ezkemboi commented 2 years ago

I would like to give this to the people who are new and would like to start contributing to validator.js.

The current version in isMobilePhone validation, we have less than 195 phone validations i.e

In the code https://github.com/validatorjs/validator.js/blob/master/src/lib/isMobilePhone.js, the validations exist from line 5 to line 119, which means we have probably 119 - 5 countries phone validations. Where might be other countries? That is up to someone who would like to choose which country does not exist and create a new validation for the same.

When making this change, apart from the file above, also add tests and update the isMobilePhone section in the README.

Also, please check on existing PR's if the country you choose to validate mobile phone numbers does not have an already PR raised.

All Prs are welcomed and we will do a review on the same

ezkemboi commented 2 years ago

Great catch, please do add @mairagee524 and reference your PR to this issue with the correct title such as phone number for Mexico(code) etc.

Thanks and looking forward to your PR. I will also double-check on the same.

pasagedev commented 2 years ago

It seems that Cuba is not on the list either, could I work on that ?

ezkemboi commented 2 years ago

Sure, please do.

On Fri, Oct 8, 2021, 8:14 PM Pablo Salas Gelich @.***> wrote:

It seems that Cuba is not on the list either, could I work on that ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/1761#issuecomment-938892563, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH756XKT3WGXB4RZAELUF4RHDANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

neel-desh commented 2 years ago

Afghanistan is also missing, working on that...

ezkemboi commented 2 years ago

Please do add and raise a Pr

On Sat, Oct 9, 2021, 3:15 PM Neel Deshmukh @.***> wrote:

Afghanistan is also missing, I belive

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/1761#issuecomment-939287602, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH3HH5S7MKWFE26FRYLUGAW57ANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

neel-desh commented 2 years ago

Please do add and raise a Pr On Sat, Oct 9, 2021, 3:15 PM Neel Deshmukh @.***> wrote: Afghanistan is also missing, I belive — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#1761 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH3HH5S7MKWFE26FRYLUGAW57ANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Yes, I did.

Btw, for new contributors, what i did was find list of the country code and their ISO codes, wrote simple program to filter non existing countries and wrote the code.

here are the resources : https://www.att.com/support_media/images/pdf/Country_Code_List.pdf https://countrycode.org/

@ezkemboi I'm not adding all the missing country code validations, i would like other people to contribute, but after October if still there are no contributions in this or we have missing validations, I would try to complete the list...

ezkemboi commented 2 years ago

Sure thing.

On Sat, Oct 9, 2021, 3:49 PM Neel Deshmukh @.***> wrote:

Please do add and raise a Pr … <#m7010722731381047102> On Sat, Oct 9, 2021, 3:15 PM Neel Deshmukh @.***> wrote: Afghanistan is also missing, I belive — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#1761 (comment) https://github.com/validatorjs/validator.js/issues/1761#issuecomment-939287602>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH3HH5S7MKWFE26FRYLUGAW57ANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

Yes, I did.

Btw, for new contributors, what i did was find list of the country code and their ISO codes, wrote simple program to filter non existing countries and wrote the code.

here are the resources : https://www.att.com/support_media/images/pdf/Country_Code_List.pdf https://countrycode.org/

@ezkemboi https://github.com/ezkemboi I'm not adding all the missing codes as, i would like other people to contribute, but after October if still there are no contributions, I would try to complete the list...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/1761#issuecomment-939291996, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH46IX2ZGVOLK4A7SZTUGA25RANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mgndolan commented 2 years ago

I didn't see Botswana on the list. Could I add this validation?

ezkemboi commented 2 years ago

@mgndolan please add that and raise a PR, I will review that.

rootkit7628 commented 2 years ago

It seems like Madagascar in not on the list. Could I add this validation?

Sidd2024 commented 2 years ago

looks like grenada is also not there in the list, should i add this a validation for this?

ezkemboi commented 2 years ago

Please do add them.

On Sun, Oct 10, 2021, 11:20 AM Siddhant Sharma @.***> wrote:

looks like grenada is also not there in the list, should i add this a validation for this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/1761#issuecomment-939429396, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH3S2B3UKSG6BKHYNQ3UGFEGFANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

lakshayr003 commented 2 years ago

It seems like Bhutan is not on the list, should I add validation for this? @ezkemboi

ezkemboi commented 2 years ago

Yes @lakshayr003

HackProAIT commented 2 years ago

It would we nice if we could write comment country name in front of each country code.

tarob0ba commented 2 years ago

I was just poking around and noticed that there wasn't an entry for Cameroon. Should I work on this?

tarob0ba commented 2 years ago

Opened PR #1772.

ezkemboi commented 2 years ago

Good stuff @beckettnormington. Thanks all for opening PRs, let's keep them coming. I will spend this week reviewing them.

Madhavi96 commented 2 years ago

@ezkemboi Hi! I previously did a contribution to this project, by adding mobile phone number validation for Sri Lanka. I was inspired to participate in Hacktoberfest this time and reached out again.

Just noticed that the contribution I added to validate mobile numbers in Sri Lanka has been replaced by this: en-SL': /^(\+?232|0)\d{8}$/

However, it does not validate mobile numbers in Sri Lanka correctly (sources: https://en.wikipedia.org/wiki/Telephone_numbers_in_Sri_Lanka).

Is there a specific reason for the change? If not, I can make the necessary changes to make it work correctly again. Thank you!

ezkemboi commented 2 years ago

Please do make the changes @Madhavi96 . But, also, I will need to make sure why it was changed and if the changes made are also necessary. Thank you.

Madhavi96 commented 2 years ago

Thanks. Let me know if you find anything on the requirement for the change. Until then I'll do the changes and raise a PR.

Madhavi96 commented 2 years ago

@ezkemboi Found the validation for Sri Lanka, under 'si-LK': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, and that is correct

Apologies for the false alarm!

ezkemboi commented 2 years ago

No worries

On Mon, Oct 11, 2021, 7:30 PM Ishara Madhavi @.***> wrote:

@ezkemboi https://github.com/ezkemboi Found the validation for Sri Lanka, under 'si-LK': /^(?:0|94|+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, and that is correct

Apologies for the false alarm!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/1761#issuecomment-940178995, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALVWPH5QRBHWNFGD4W3X6YLUGMGKLANCNFSM5FSXM3NQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

rohitnairtech commented 2 years ago

@ezkemboi I created a pull request but the npm test failed even though it runs successfully on my local machine, Im using node v14.18.0 and npm v6.14.15

PR:- added brunei (ms-BN)

Error- Unexpected token ) Referenced from: /home/runner/work/validator.js/validator.js/node_modules/eslint-config-airbnb-base/index.js Referenced from: /home/runner/work/validator.js/validator.js/.eslintrc.json /home/runner/work/validator.js/validator.js/node_modules/eslint-module-utils/parse.js:97 ); ^ npm ERR! Failed at the validator@13.6.0 lint script 'eslint src test'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the validator package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! eslint src test

Issue happens for test on Nodejs 6

PR code - #1776

lakshayr003 commented 2 years ago

Hi @ezkemboi , I have submitted the PR #1770, I am a first time contributor so it would be great if you could check if I have followed all the steps correctly?

atom19-i commented 2 years ago

It seems Croatia isn't on the list. could i work on that?

ezkemboi commented 2 years ago

Good stuff

Madhavi96 commented 2 years ago

Hi, I have done an enhancement to the mobile number validation regex used for Sri Lanka and submitted the PR.

borm commented 2 years ago

some business customer in Estonia may want to use +3726xxxxx for their phone nr, but validation does`t allows us to use it

'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,

PS, im not from Estonia, got this information from my client

tux-tn commented 2 years ago

@borm thank you for your feedback ! Feel free to open a separate issue if you think it's a bug or if you can/want a new PR if you think you can fix it

letsaguiar commented 2 years ago

It doesn't look like Haiti is on this list - I can add it?

crisjumbo commented 2 years ago

El Salvador is not in the list. I will add it :D

tux-tn commented 2 years ago

El Salvador is not in the list. I will add it :D

Someone already opened a PR for Salvador

Pranai2518 commented 2 years ago

Looks like Argentina is not on the list. Can I add it?

pasagedev commented 2 years ago

Looks like Argentina is not on the list. Can I add it?

Argentina is on the list

sumitkumarju commented 2 years ago

Looks like Morocco is not on the list. Can I add it?

siddharth-sable commented 2 years ago

Hi, I did see India was not on the list. Added regex successfully. All tests passed #1805

zolezzi commented 2 years ago

Looks like Croatia is not on the list. Can I add it?

Tharunkumar1411 commented 2 years ago

Looks like America Samoa is not there. Can i fix it?

atom19-i commented 2 years ago

@zolezzi I have already submitted PR for croatia #1779.

zolezzi commented 2 years ago

@atom19-i Thanks! I did not see your comment, sorry! Looking at the comments and validations, Qatar is not in the list, can I add it?

tux-tn commented 2 years ago

@atom19-i Thanks! I did not see your comment, sorry! Looking at the comments and validations, Qatar is not in the list, can I add it?

You can add any locale as long as it doesn't already exist and there is no open PR for it or someone that requested to add it before you!

Prajwalrajbasnet commented 2 years ago

I don't see Maldives in the list currently. I'll pick that up.

ferdousulhaque commented 2 years ago

@ezkemboi I have updated Bangladesh and added Myanmar mobile number validation. Can you please approve.

c-tanner commented 2 years ago

Added Jamaica validation in #1819

c-tanner commented 2 years ago

Added Kiribati validation in #1820

ZeeMangena commented 2 years ago

Namibia validation needed?

danielTiringer commented 2 years ago

There's already a regex for the Hungarian mobile numbers, but it is incomplete. It is missing the internal country code option (06 instead of +36), and there are also new area codes added in the past few years that are not included. It would also be nice if it was covered with a few test cases. Should this be an issue on its own, or could I raise a PR against this one and get it updated?

tux-tn commented 2 years ago

There's already a regex for the Hungarian mobile numbers, but it is incomplete. It is missing the internal country code option (06 instead of +36), and there are also new area codes added in the past few years that are not included. It would also be nice if it was covered with a few test cases. Should this be an issue on its own, or could I raise a PR against this one and get it updated?

Feel free to open a new PR. No need to create a new issue!

tux-tn commented 2 years ago

Many thanks to all the people that participated as part of Hacktoberfest. We had 28 Pull requests merged 🎉 !