Skip to content

Commit

Permalink
Merge pull request #10 from personnummer/develop
Browse files Browse the repository at this point in the history
Fix acceptance of '000' sequence in Personnummer num part
  • Loading branch information
VoxSecundus authored Jun 16, 2020
2 parents 0fa2de9 + 1ba7e0c commit a7a2ceb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/personnummer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def is_female?
# Raises error if regex is refused.
# (Hash)
def get_parts(personnummer)
reg = /^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\-|\+]{0,1})?(\d{3})(\d{0,1})$/;
reg = /(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-\s]?)((?!000)\d{3})(\d)/;
match = personnummer.to_s.match(reg)

if !match
Expand Down
1 change: 1 addition & 0 deletions test/test_personnummer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_wrong_personnummer_or_types
assert_equal false, Personnummer::valid?('990919+3776')
assert_equal false, Personnummer::valid?('990919-3776')
assert_equal false, Personnummer::valid?('9909193776')
assert_equal false, Personnummer::valid?('20150916-0006')
end

def test_coordination_numbers
Expand Down

0 comments on commit a7a2ceb

Please sign in to comment.