diff --git a/CHANGELOG.md b/CHANGELOG.md index 7470211..5d8bcac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,19 @@ ## [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 @@ -18,9 +21,9 @@ 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 @@ -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 diff --git a/README.md b/README.md index 7acd8cc..65291a7 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lib/tin_valid/netherlands_tin.rb b/lib/tin_valid/netherlands_tin.rb index 9883f9d..11732e3 100644 --- a/lib/tin_valid/netherlands_tin.rb +++ b/lib/tin_valid/netherlands_tin.rb @@ -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 diff --git a/lib/tin_valid/tin.rb b/lib/tin_valid/tin.rb index c5fed35..698a7e3 100644 --- a/lib/tin_valid/tin.rb +++ b/lib/tin_valid/tin.rb @@ -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? diff --git a/spec/tin_valid/netherlands_tin_spec.rb b/spec/tin_valid/netherlands_tin_spec.rb index 9ff1bec..f602211 100644 --- a/spec/tin_valid/netherlands_tin_spec.rb +++ b/spec/tin_valid/netherlands_tin_spec.rb @@ -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