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

Assign check digit to 0 if remainder is 10 #2492

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Conversation

joelcuy
Copy link
Contributor

@joelcuy joelcuy commented Nov 12, 2024

Title:

feat(isISO6346): improve ISO6346 container ID validation with checksum adjustments

Description:

This PR enhances the isISO6346 validator to comply more accurately with the ISO 6346 standard, specifically addressing checksum validation for container IDs where the checksum result is 10. According to the standard, if the checksum is 10, the check digit should be represented as 0. This update improves accuracy in validating container IDs, particularly for freight containers (category 'U') where the checksum is mandatory.

Changes include:

  • Adjusting checksum validation to handle cases where the checksum is 10, setting the check digit to 0 as per the standard.
  • Adding tests for container IDs with check digits of 0 (when the checksum is 10) to ensure the validator correctly processes edge cases.

References:

"If the final difference is 10, then the check digit becomes 0. To ensure that this does not happen the standard recommends that serial numbers should not be used which produce a final difference of 10; however, there are containers in the market which do not follow this recommendation, so handling this case has to be included if a check digit calculator is programmed."

I think this should be considered as I'm currently working for a logistics company and we get container numbers that end with 0 (checksum is 10) very often. Hence, decided to help contribute. Let me know what you think!

Checklist

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

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.96%. Comparing base (f81d857) to head (de21f8d).
Report is 13 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master    #2492      +/-   ##
===========================================
- Coverage   100.00%   99.96%   -0.04%     
===========================================
  Files          110      111       +1     
  Lines         2510     2523      +13     
  Branches       633      638       +5     
===========================================
+ Hits          2510     2522      +12     
- Partials         0        1       +1     

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

@WikiRik WikiRik requested a review from rubiin November 12, 2024 14:42
@WikiRik
Copy link
Member

WikiRik commented Nov 12, 2024

Failing check is not due to your change, so this all looks good to me. After a second approval we can merge this

@rubiin rubiin merged commit a066cd2 into validatorjs:master Nov 12, 2024
11 of 12 checks passed
@joelcuy
Copy link
Contributor Author

joelcuy commented Nov 12, 2024

Cheers Thank you!

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.

3 participants