Skip to content

Add Vin (identifiers) #20

@vhrcgcom

Description

@vhrcgcom

Description

Implement Vin as a ValueObject in the identifiers module.

Spec: Vehicle Identification Number, 17 chars, checksum validated

Implementation checklist

  • Create src/identifiers/vin.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 VinInput
Output String VinOutput

Normalization

Trim, convert to uppercase.

Validation

  • Exactly 17 characters after normalising.
  • Only ASCII letters and digits; the letters I, O, and Q are forbidden (they are excluded from the VIN alphabet to avoid confusion with 1, 0, and 0).
  • Check digit (position 9, 0-indexed) must be valid: each character has a transliteration value and a positional weight; compute weighted sum mod 11 and compare against the stored check digit (0–9 or X for 10).

Extra methods

  • wmi() -> &str — World Manufacturer Identifier, first 3 characters.
  • vds() -> &str — Vehicle Descriptor Section, characters 4–9.
  • vis() -> &str — Vehicle Identifier Section, last 8 characters (includes model year and serial number).
  • model_year() -> char — character at position 10 (index 9), encodes the model year.

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