Skip to content

regex added for Senegal sn-SN #2304

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Akilan19
Copy link

@Akilan19 Akilan19 commented Oct 2, 2023

Validations added for Senegal - Issue #1761

  • isMobilePhone regex added for 'sn-SN'. Reference -Telephone_numbers_in_Senegal
  • isPostalCode regex added for 'SN'. Reference
  • Relevant unit test added & Readme updated.

CHECKLIST

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
    image

@codecov
Copy link

codecov bot commented Oct 2, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (b958bd7) 99.95% compared to head (011da84) 99.95%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2304      +/-   ##
==========================================
- Coverage   99.95%   99.95%   -0.01%     
==========================================
  Files         107      107              
  Lines        2454     2449       -5     
  Branches      619      619              
==========================================
- Hits         2453     2448       -5     
  Partials        1        1              
Files Coverage Δ
src/lib/isMobilePhone.js 100.00% <ø> (ø)
src/lib/isPostalCode.js 100.00% <ø> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Akilan19 Akilan19 marked this pull request as ready for review October 2, 2023 13:46
Copy link
Member

Choose a reason for hiding this comment

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

Please add SN to the list of locales of isPostalCode as well

Comment on lines +75 to +78
"license": "MIT",
"dependencies": {
"validator": "^13.11.0"
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"license": "MIT",
"dependencies": {
"validator": "^13.11.0"
}
"license": "MIT"

@@ -73,6 +73,7 @@ const patterns = {
US: /^\d{5}(-\d{4})?$/,
ZA: fourDigit,
ZM: fiveDigit,
SN: fiveDigit,
Copy link
Member

Choose a reason for hiding this comment

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

Please add tests for this as well. Also; can you provide a source for this?

@@ -159,6 +159,7 @@ const phones = {
'ar-YE': /^(((\+|00)9677|0?7)[0137]\d{7}|((\+|00)967|0)[1-7]\d{6})$/,
'ar-EH': /^(\+?212|0)[\s\-]?(5288|5289)[\s\-]?\d{5}$/,
'fa-AF': /^(\+93|0)?(2{1}[0-8]{1}|[3-5]{1}[0-4]{1})(\d{7})$/,
'sn-SN': /^(221|00221|\+221)?(77|78|75|70|76)[0-9]{7}$/,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'sn-SN': /^(221|00221|\+221)?(77|78|75|70|76)[0-9]{7}$/,
'sn-SN': /^(\+?221|0)?(70|72|7[5-9])[0-9]{7}$/,

According to the most recent document in https://www.itu.int/oth/T02020000B8/en , this should be the regular expression. I have also updated the first part to be more in line with other locales (even though there are major inconsistencies)
Tests should also be updated for this

Please also move this to it's proper alphabetical location, like in the README.

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.

2 participants