Skip to content
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

Refactor isTaxID for supporting more locales #1409

Merged
merged 1 commit into from
Sep 21, 2020

Conversation

dspinellis
Copy link
Contributor

@dspinellis dspinellis commented Aug 15, 2020

  • Prefix US-related functionality with "enUs"
  • Remove assumption of global IRS-like campus prefixes
  • Move US prefix check into separate function
  • Add per-locale check function lookup table
  • Support future locales lacking a check function (e.g. UK)
  • Remove unneeded sorting of the IRS campus prefixes
  • Add comments

Checklist

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

* Prefix US-related functionality with "enUs"
* Remove assumption of global IRS-like campus prefixes
* Move US prefix check into separate function
* Add per-locale check function lookup table
* Support future locales lacking a check function (e.g. UK)
* Remove unneeded sorting of the IRS campus prefixes
* Add comments
@codecov
Copy link

codecov bot commented Aug 15, 2020

Codecov Report

Merging #1409 into master will decrease coverage by 0.07%.
The diff coverage is 88.88%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master    #1409      +/-   ##
===========================================
- Coverage   100.00%   99.92%   -0.08%     
===========================================
  Files           95       95              
  Lines         1248     1251       +3     
===========================================
+ Hits          1248     1250       +2     
- Misses           0        1       +1     
Impacted Files Coverage Δ
src/lib/isTaxID.js 94.73% <88.88%> (-5.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed86b0a...2368cb4. Read the comment docs.

@dspinellis
Copy link
Contributor Author

Code coverage will increase once another locale is supported (and tested). However, I think that this should be a separate commit.

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM, could you add the tests still as part of this PR?

/cc. @tux-tn @ezkemboi pls review.

@dspinellis
Copy link
Contributor Author

For more tests to be added I'll need to add support for another locale. I don't think that such a change should be part of this PR.

One of my students has completed support for many more locales (including tests), and is ready to issue a PR once this gets accepted.

@ezkemboi
Copy link
Member

@dspinellis what about we just add tests for the one locale/s currently supported/written here.
Leaving tests for code already written sometimes brings us back to add them, which could have been easy to make it inclusive of code.
As part of encouraging the students to see the best practice, I would suggest we add a test for this one as we wait for the other locales and its tests.
Also, tests give us surety of what we should expect to pass and what should fail. Without tests, it will not be easy for me/other developers to review the work as we will be forced to run against our own tests.
Once the test is added, I would love to review it.

@dspinellis
Copy link
Contributor Author

The locale currently supported is already unit-tested; I wouldn't commit code without unit tests.

@dspinellis
Copy link
Contributor Author

Here is the corresponding test.

@profnandaa profnandaa merged commit 7801390 into validatorjs:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants