Skip to content

Faker.Vehicle.vin() does not always generate valid VINs #507

Open
@robacarp

Description

@robacarp

In US/CA, the final digit of a VIN is a check digit.

Faker currently just picks a random digit and finishes the VIN with that. As a result, about 70% of the time faker generates invalid VINs.

  # Faker does not always generate valid VINs :(
  def vin_factory(_attrs) do
    vin = Faker.Vehicle.vin()

    vin
    |> Vin.valid_vin_string?()
    |> case do
      :ok -> vin
      {:error, _} -> build(:vin)
    end
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions