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

da-DK license plates #3010

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

da-DK license plates #3010

wants to merge 4 commits into from

Conversation

woller
Copy link

@woller woller commented Oct 14, 2024

Motivation / Background

This Pull Request has been created because it was not possible to generate valid Danish license plates. It adds the simplest possible license plates consisting of 2 letters and 5 digits. It follows the rules laid out on the Danish Wikipedia.

Additional information

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug, refactor something, or add a feature.
  • Tests and Rubocop are passing before submitting your proposed changes.

If you're proposing a new generator or locale:

  • Double-check the existing generators documentation to make sure the new generator you want to add doesn't already exist.
  • You've reviewed and followed the Contributing guidelines.

lib/locales/da-DK.yml Outdated Show resolved Hide resolved
@@ -60,4 +60,8 @@ def test_da_dk_counrty_code
assert_match(/(\+45)[\s](\d\d[\s-]?){4}$/, Faker::PhoneNumber.phone_number_with_country_code)
assert_match(/(\+45)[\s](\d\d[\s-]?){4}$/, Faker::PhoneNumber.cell_phone_with_country_code)
end

def test_da_dk_license_plate
assert_match(/^(O[A-HJ-NPR-Z](?![BHBUCCCDDKDUEUKZMUYPSSUDUNVC])|[A-HJ-NPR-Z]{2})(\d{2,5})$/, Faker::Vehicle.license_plate)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks too convoluted. What do you think of taking doing something like this:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is convoluted, but I think your suggestion got cut off - unless you want to really simplify it 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, my bad! Changing computers mess up with my keyboard shortcuts 🙈

I meant something like:

assert_match(/^[A-Z]{2}-[0-9]{5}/, Faker::Vehicle.license_plate)

@stefannibrasil
Copy link
Contributor

Could you also add screenshots of using this in the console (bundle exec rake console)? Thanks!

@woller
Copy link
Author

woller commented Oct 18, 2024

image

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.

2 participants