-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Add en-GB ID Numbers (aka National Insurance Numbers) #3032
base: main
Are you sure you want to change the base?
Add en-GB ID Numbers (aka National Insurance Numbers) #3032
Conversation
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.
5fe1451
to
41ea916
Compare
There was a problem hiding this 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
Great shout! I've attempted to document it in the same style and writing style. Happy to rewrite according to any examples. Feedback very welcome, I doubt you could offend me. 😄 |
There was a problem hiding this 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.
Besides the locale-specific ID Number methods. Faker supports retrieving localised calls to `.valid` and `.invalid`. | ||
Here is an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the locale-specific ID Number methods. Faker supports retrieving localised calls to `.valid` and `.invalid`. | |
Here is an example: | |
Besides the default ID Number methods, Faker supports localized `.valid` and `.invalid` values. Here is an example: |
### en-GB | ||
When provided with British English, unformatted'[National Insurance](https://www.gov.uk/national-insurance/your-national-insurance-number)' numbers are generated. | ||
Note: Faker can only generate a subset of all possible legal/illegal national insurance numbers. | ||
|
||
```ruby | ||
Faker::Config.locale = 'en-GB' | ||
Faker::IdNumber.valid #=> "AJ405924A" | ||
Faker::IdNumber.invalid #=> "BG316764W" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### en-GB | |
When provided with British English, unformatted'[National Insurance](https://www.gov.uk/national-insurance/your-national-insurance-number)' numbers are generated. | |
Note: Faker can only generate a subset of all possible legal/illegal national insurance numbers. | |
```ruby | |
Faker::Config.locale = 'en-GB' | |
Faker::IdNumber.valid #=> "AJ405924A" | |
Faker::IdNumber.invalid #=> "BG316764W" | |
``` | |
### en-GB | |
When the locale is set to British English, unformatted'[National Insurance](https://www.gov.uk/national-insurance/your-national-insurance-number)' numbers are generated: | |
```ruby | |
Faker::Config.locale = 'en-GB' | |
Faker::IdNumber.valid #=> "AJ405924A" | |
Faker::IdNumber.invalid #=> "BG316764W" |
Note: Faker generates a subset of all possible legal/illegal national insurance numbers.
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:
[Fix #issue-number]
If you're proposing a new generator or locale: