Skip to content

Add identifiers module (v0.4.0)#85

Merged
codegresscom merged 1 commit intomainfrom
feat/12-20-identifiers
Apr 20, 2026
Merged

Add identifiers module (v0.4.0)#85
codegresscom merged 1 commit intomainfrom
feat/12-20-identifiers

Conversation

@vhrcgcom
Copy link
Copy Markdown
Collaborator

@vhrcgcom vhrcgcom commented Apr 20, 2026

Summary

Implements the full identifiers module (v0.4.0) — 7 value objects with checksum validation.

Type Spec
Slug lowercase [a-z0-9-], no leading/trailing/consecutive hyphens
Ean13 13 digits, GS1 checksum
Ean8 8 digits, GS1 checksum
Isbn13 13 digits, prefix 978/979, EAN-13 checksum
Isbn10 10 chars, check char 0–9 or X, weighted sum mod 11
Issn 8 chars, check char 0–9 or X, weighted sum mod 11; output XXXX-XXXX
Vin 17 chars, I/O/Q forbidden, check digit mod 11 per ISO 3779

Note on EAN checksum: EAN-8 and EAN-13 share the same GS1 right-to-left algorithm; the weight depends on distance from the right edge ((n-i) % 2), so the starting weight from the left differs for even-length (EAN-8) and odd-length (EAN-13) codes.

Closes #12
Closes #15
Closes #16
Closes #17
Closes #18
Closes #19
Closes #20

Type of change

  • Bug fix
  • New value object / feature
  • Documentation
  • Refactor / internal improvement
  • CI / tooling

Checklist

  • cargo fmt — code is formatted
  • cargo clippy --features full,serde -- -Dclippy::all — no warnings
  • cargo test --features full,serde — all tests pass (165/165)
  • New public API has doc comments with an # Example block
  • New value objects have tests for: valid input, empty input, invalid format, normalisation
  • README feature table updated (if a new feature was added)

7 value objects: Slug, Ean13, Ean8, Isbn13, Isbn10, Issn, Vin.

EAN weight scheme uses length-aware formula (weight = 3 if even distance
from right, 1 if odd) — this correctly handles both EAN-8 and EAN-13
without a separate implementation.

Closes #12, #15, #16, #17, #18, #19, #20

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codegresscom codegresscom merged commit 0238f83 into main Apr 20, 2026
14 checks passed
@codegresscom codegresscom deleted the feat/12-20-identifiers branch April 20, 2026 19:19
vhrcgcom pushed a commit that referenced this pull request Apr 21, 2026
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.

Add Isbn10 (identifiers) Add Isbn13 (identifiers) Add Ean8 (identifiers) Add Ean13 (identifiers) Add Slug (identifiers)

2 participants