Skip to content

Conversation

@stefanjcollier
Copy link
Contributor

Motivation / Background

In GB, we use national insurance numbers as our primary citizen identification numbers.

Additional information

National Insurance Numbers are 9 digit strings that are typically 2 alpha characters followed by 6 numbers and finally a single alpha. There are few combinations are not permitted as seen here.

The valid regex provided will produce a subset of all legal NI numbers. I didn't consider a regex to produce all combinations wasn't necessary.

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.

@stefanjcollier stefanjcollier marked this pull request as ready for review December 5, 2024 18:36
@stefanjcollier stefanjcollier marked this pull request as draft December 5, 2024 18:37
In GB, we use [national insurance numbers](https://www.gov.uk/national-insurance/your-national-insurance-number) as our primary citizen identification numbers.

These are 9 digit strings that are typically 2 alpha characters followed by 6 numbers and finally a single alpha. There are few combinations are not permitted [as seen here](https://www.gov.uk/hmrc-internal-manuals/national-insurance-manual/nim39110).

The `valid` code provided will produce a subset of all legal NI numbers. A regex in the locale file to produce all combinations isn't necessary.
@stefanjcollier stefanjcollier marked this pull request as ready for review December 5, 2024 18:44
@stefanjcollier
Copy link
Contributor Author

Faker::IdNumber.valid

image

Faker::IdNumber.invalid

image

@stefanjcollier stefanjcollier changed the title Add GB National Insurance Numbers aka ID Numbers Add GB ID Numbers (aka National Insurance Numbers) Dec 5, 2024
@stefanjcollier stefanjcollier changed the title Add GB ID Numbers (aka National Insurance Numbers) Add en-GB ID Numbers (aka National Insurance Numbers) Dec 6, 2024
Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

Thank you for the screenshots! What do you think of adding a note in the documentation for this locale that the result will be normalized? The doc could have a section for locales: https://github.com/faker-ruby/faker/blob/main/doc/default/id_number.md?plain=1

@stefanjcollier
Copy link
Contributor Author

stefanjcollier commented Jan 8, 2025

Great shout! I've attempted to document it in the same style and writing style.
I hope this was how you were intending?

Happy to rewrite according to any examples. Feedback very welcome, I doubt you could offend me. 😄

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

Thank you @stefanjcollier I left some suggestions.

@thdaraujo thdaraujo added the Stale label Nov 1, 2025
@thdaraujo
Copy link
Contributor

just checking in on this PR, @stefanjcollier. Please address the previous comments when you have some time.

Thanks!

Copy link
Contributor

@stefannibrasil stefannibrasil left a comment

Choose a reason for hiding this comment

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

I've committed the suggestions on this branch. Thanks for improving faker!

@stefannibrasil stefannibrasil merged commit 3de3f9c into faker-ruby:main Nov 18, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants