Skip to content

Commit

Permalink
Add not_in_registry? method
Browse files Browse the repository at this point in the history
  • Loading branch information
krmbzds committed Jul 6, 2023
1 parent 15231d3 commit 7606451
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/turkish_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def registered?(given_name, surname, year_of_birth)
valid? && query_government_registry(given_name, surname, year_of_birth)
end

def not_in_registry?(given_name, surname, year_of_birth)
!valid? || !query_government_registry(given_name, surname, year_of_birth)
end

private

def calculate_checksum(id_array)
Expand Down
2 changes: 1 addition & 1 deletion spec/turkish_id_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
it "checks government registry for numerically valid unregistered id number" do
identity_number = TurkishId.new(99_997_183_780)
expect(identity_number.valid?).to eq(true)
expect(identity_number.registered?("RaveBase", "Phase 9", 1997)).to eq(false)
expect(identity_number.not_in_registry?("RaveBase", "Phase 9", 1997)).to eq(true)
end

it "does not query government registry for invalid id number" do
Expand Down

0 comments on commit 7606451

Please sign in to comment.