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 generating Latvian id number #1490

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

cbxp
Copy link
Contributor

@cbxp cbxp commented Jan 27, 2025

  • We support two formats: old (before 01.07.2017) and new (since 01.07.2017)
  • For generating invalid ID numbers, we use only the old format (for simplicity)

-) we support two formats: old (before 01.07.2017) and new
-) Only old format of the id number is used for invalid numbers
Copy link

what-the-diff bot commented Jan 27, 2025

PR Summary

  • Creation of a New Class for Latvian Identification Numbers
    This update includes the creation of a new class known as LatvianIdNumber. Its specific role is to generate valid and, if needed, invalid Latvian identification numbers, enhancing the flexibility of our system.

  • Introduction of Valid Identification Number Generation Methods
    We've implemented advanced methods able to generate valid identification numbers based on key parameters such as date of birth and gender. The new methods are designed to accurately distinguish between old and new ID formats, ensuring up-to-date compatibility.

  • Inclusion of Checksum Calculation
    To further fortify our system's ID validation process, we've added a checksum computation to the ID numbers to verify their integrity according to the mandated format.

  • Service File Adjusted to Support New Class
    Our service file has been promptly updated to incorporate the LatvianIdNumber in the roster of ID number generators, bolstering the available options for users.

  • Development of Unit Tests for Latvian Identification Numbers
    Critical to ensuring the seamless operation of this new feature, we've developed corresponding unit tests denoted as LatvianIdNumberTest. These tests validate the checksum calculations and confirm the ID number format conforms to both old and new versions.

  • Expansion of Existing Tests
    Going beyond the new feature, we've also intensified our existing testing suite in IdNumberTest. This fortified suite now encompasses additional tests for both valid and invalid Latvian ID numbers, thus enhancing our system’s overall functionality and precision.

@codecov-commenter
Copy link

codecov-commenter commented Jan 27, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.41%. Comparing base (ebac66a) to head (a6d49d3).

Files with missing lines Patch % Lines
.../java/net/datafaker/idnumbers/LatvianIdNumber.java 93.33% 1 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1490      +/-   ##
============================================
- Coverage     92.45%   92.41%   -0.05%     
- Complexity     3255     3265      +10     
============================================
  Files           324      325       +1     
  Lines          6387     6417      +30     
  Branches        623      625       +2     
============================================
+ Hits           5905     5930      +25     
  Misses          336      336              
- Partials        146      151       +5     

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

case 18 -> 0;
case 19 -> 1;
case 20 -> 2;
default -> throw new IllegalStateException("Too far in future: " + birthYear);
Copy link
Collaborator

@snuyanzin snuyanzin Jan 27, 2025

Choose a reason for hiding this comment

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

nit: i guess in case of year 1700 it will fail with Too far in future: 1700 which doesn't sound like true
may be something like out of allowed range [1800, 2100) would fit better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, error message improved.

@cbxp cbxp requested a review from snuyanzin January 27, 2025 12:35
@asolntsev asolntsev self-requested a review January 27, 2025 12:54
@asolntsev asolntsev added this to the 2.4.3 milestone Jan 27, 2025
@asolntsev asolntsev merged commit 2899094 into datafaker-net:main Jan 27, 2025
10 checks passed
@cbxp cbxp deleted the feature/latvian-id-number branch January 27, 2025 14:24
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.

4 participants