Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 13 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
## [Unreleased]

Fixes:
- Accept RSIN format for companies in the Netherlands 🇳🇱

## [1.3.2] - 2026-05-25

Fixes:
- Fix Denmark to ignore a `-` 🇩🇰
- Ignore a `-` for Denmark 🇩🇰

## [1.3.1] - 2026-03-24

Fixes:
- Fix Belgium to ignore `-` and `.` 🇧🇪
- Fix Czechia to accept `CZ` prefix 🇨🇿
- Fix Sweden TINs versions with 4-digit years 🇸🇪
- Ignore `-` and `.` for Belgium 🇧🇪
- Accept `CZ` prefix for Czechia 🇨🇿
- Accept TINs versions with 4-digit years for Sweden 🇸🇪

## [1.3.0] - 2025-12-12

Features:
- Add `TinValid::COUNTRY_CODES` to get available country codes.

Fixes:
- Fix Bulgaria to accept TINs starting with `10` instead of `00` 🇧🇬
- Fix Finland checks for tins ending in `P` 🇫🇮
- Fix Denmark check for certain ranges of birth years 🇩🇰
- Accept TINs starting with `10` instead of `00` for Bulgaria 🇧🇬
- Fix check for TINs ending in `P` for Finland 🇫🇮
- Fix check for certain ranges of birth years for Denmark 🇩🇰

## [1.2.1] - 2025-05-22

Expand All @@ -41,14 +44,14 @@ Fixes:
## [1.1.2] - 2025-05-06

Fixes:
- Fix Luxembourg check 🇱🇺
- Fix check for Luxembourg 🇱🇺
- Accept SIREN for France 🇫🇷

## [1.1.1] - 2025-04-28

Fixes:
- Fix birth date check for Italy when year is between 1900..1909 or between
2000..2009 🇮🇹
- Fix birth date check when year is between 1900..1909 or between 2000..2009 for
Italy 🇮🇹

## [1.1.0] - 2025-04-18

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ TinValid::MaltaTin.new(tin: "1234567A").valid?
### Netherlands 🇳🇱 (nl)

```rb
TinValid::NetherlandsTin.new(tin: "174559434").valid?
TinValid::NetherlandsTin.new(
tin: "174559434",
kind: "individual", # optional, can be "individual" or "company"
).valid?
```

### Poland 🇵🇱 (pl)
Expand Down
14 changes: 11 additions & 3 deletions lib/tin_valid/netherlands_tin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

module TinValid
class NetherlandsTin
def initialize(tin:)
def initialize(tin:, kind: nil)
@tin = tin
@kind = kind.to_s
end

attr_reader :tin
attr_reader :tin, :kind

def valid?
return false unless /\A[0-9]{9}\z/.match?(tin)
return false if tin == "000000000"

tin[-1].to_i == check
if kind == "individual"
# BSN (Burgerservicenummer)
tin[-1].to_i == check
else
# No public algorithm found for checking the RSIN (Rechtspersonen en
# Samenwerkingsverbanden Informatienummer)
true
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/tin_valid/tin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def valid?
in "lu" then LuxembourgTin.new(tin:, birth_date:).valid?
in "lv" then LatviaTin.new(tin:, birth_date:).valid?
in "mt" then MaltaTin.new(tin:).valid?
in "nl" then NetherlandsTin.new(tin:).valid?
in "nl" then NetherlandsTin.new(tin:, kind:).valid?
in "pl" then PolandTin.new(tin:, birth_date:).valid?
in "pt" then PortugalTin.new(tin:).valid?
in "ro" then RomaniaTin.new(tin:, birth_date:).valid?
Expand Down
50 changes: 35 additions & 15 deletions spec/tin_valid/netherlands_tin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,49 @@

RSpec.describe TinValid::NetherlandsTin do
describe "#valid?" do
valid_values = %w[
174559434
# rubocop:disable Style/WordArray
valid_values = [
["174559434", "individual"],
["174559434", "company"],
["174559434", nil],
["174559439", "company"],
["174559439", nil],
]

invalid_values = [
"1745594349",
"17455943",
"174559439",
"000000000",
"123456789",
nil,
"",
["1745594349", "individual"],
["1745594349", "company"],
["1745594349", nil],
["17455943", "individual"],
["17455943", "company"],
["17455943", nil],
["000000000", "individual"],
["000000000", "company"],
["000000000", nil],
[nil, "individual"],
[nil, "company"],
[nil, nil],
["", "individual"],
["", "company"],
["", nil],
["123456789", "individual"],
["174559439", "individual"],
]
# rubocop:enable Style/WordArray

valid_values.each do |tin|
context "with valid #{tin.inspect}" do
it { expect(described_class.new(tin:).valid?).to be(true) }
valid_values.each do |(tin, kind)|
context(
"with valid #{tin.inspect} and kind #{kind.inspect}",
) do
it { expect(described_class.new(tin:, kind:).valid?).to be(true) }
end
end

invalid_values.each do |tin|
context "with invalid #{tin.inspect}" do
it { expect(described_class.new(tin:).valid?).to be(false) }
invalid_values.each do |(tin, kind)|
context(
"with invalid #{tin.inspect} and kind #{kind.inspect}",
) do
it { expect(described_class.new(tin:, kind:).valid?).to be(false) }
end
end
end
Expand Down
Loading