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

Added support for zh-HK in isIdentityCard #2142

Merged
merged 10 commits into from
Jan 20, 2023

Conversation

songyuew
Copy link
Contributor

@songyuew songyuew commented Jan 4, 2023

Added support for zh-HK in isIdentityCard

Supports validation for HKID (Hong Kong Identity Card)

RegEx and checksum used, compatible with new HKIDs starting with 2 letters.

Checklist

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

@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (4350655) compared to base (531dc7f).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2142   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          104       104           
  Lines         2308      2328   +20     
  Branches       578       584    +6     
=========================================
+ Hits          2308      2328   +20     
Impacted Files Coverage Δ
src/lib/isIdentityCard.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

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, thanks for the contrib! 🎉

@profnandaa profnandaa merged commit c19777a into validatorjs:master Jan 20, 2023
@pano9000
Copy link
Contributor

kind of overlooked this, but question here is the same regarding the usage of
str = str.trim();

should sanitizing the string really be part of the validator? I would say "no".
see also my explanation here:
#2143

@songyuew
Copy link
Contributor Author

Apologies for not noticing this point. Actually, I share the same thought with you: this validator should only take care about the validation part. However, I noticed other contributors in isIdentityCard.js all wrote codes to sanitize the incoming string:

const sanitized = str.trim().toUpperCase();

const sanitized = str.trim();

To make my codes consistent with others, I believe it is better to keep the sanitization before validation.

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.

3 participants