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

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

Open
robacarp opened this issue May 17, 2023 · 0 comments · May be fixed by #508
Open

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

robacarp opened this issue May 17, 2023 · 0 comments · May be fixed by #508

Comments

@robacarp
Copy link

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
@rubysolo rubysolo linked a pull request May 18, 2023 that will close this issue
2 tasks
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 a pull request may close this issue.

1 participant