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

Add en-GB ID Numbers (aka National Insurance Numbers) #3032

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/locales/en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ en-GB:
- Northern Ireland
default_country_code:
- GB
id_number:
valid: '/[A-CEGHJ-NOPR-TW-Z][ACEHJLMOPRSW][0-9]{6}[ABCD]/'
invalid: '/(BG|GB|NK|KN|TN|NT|ZZ)[0-9]{6}[E-Z]{1}/'
internet:
domain_suffix:
- co.uk
Expand Down
14 changes: 14 additions & 0 deletions test/test_en_gb_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,18 @@ def test_en_gb_postcode_outcode_is_valid
assert_match(/^[A-PR-UWYZ][A-HK-Y0-9]/, outcode)
assert_match(/\w{1,2}\d{1,2}|\w\d[ABCDEFGHJKPSTUW]|\w\w\d[ABEHMNPRVWXY]/, outcode)
end

def test_en_gb_id_number_valid_is_valid
id_code = Faker::IdNumber.valid

assert_equal(9, id_code.length)
assert_match(/^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z][0-9]{6}[A-DFM]$/, id_code)
end

def test_en_gb_id_number_invalid_is_invalid
id_code = Faker::IdNumber.invalid

assert_equal(9, id_code.length)
assert_not_match(/^[A-CEGHJ-PR-TW-Z][A-CEGHJ-NPR-TW-Z][0-9]{6}[A-DFM]$/, id_code)
end
end