Skip to content

Add Ean8 (identifiers) #16

@vhrcgcom

Description

@vhrcgcom

Description

Implement Ean8 as a ValueObject in the identifiers module.

Spec: EAN-8 barcode with checksum validation

Implementation checklist

  • Create src/identifiers/ean8.rs
  • Implement ValueObject trait
  • Add #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
  • Export from src/identifiers/mod.rs and prelude
  • Unit tests: valid input · empty input · invalid format · normalisation
  • Doc comment with # Example block
  • Update status in ROADMAP.md from ⬜ to ✅

Implementation detail

Input / Output

Type Alias
Input String Ean8Input
Output String Ean8Output

Normalization

Strip all spaces and hyphens, keep only digits.

Validation

  • Exactly 8 digits after stripping.
  • Last digit is a valid EAN-8 check digit (same algorithm as EAN-13 but applied to 8 digits).

Extra methods

  • check_digit() -> u8 — returns the check digit (last digit).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions