ibandit 1.36.0 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8bfd630aac225e15cb3f9da75e76cdd628ab808f882b6722421f6fea17660fa
4
- data.tar.gz: 345b0848da39eed06d67eddd34e89ab9f744730a3a887c92f950778a2a479be3
3
+ metadata.gz: b92de6a0bd5136fae90ea72a6c9ef38aa44d78adcce93829217f92aaa6e06832
4
+ data.tar.gz: 397a26e1d180a102c9317527c43849d6c147adc2b30394563046a7214ec292b4
5
5
  SHA512:
6
- metadata.gz: 9789b4df93ee4c41d587dfc8272504af058e2b088be8027e938d3ab8bc8da364e9eb9c3e1ace667e267f828236867566c606a14237d1b1440ade115865480e65
7
- data.tar.gz: 421bdbf2a1acc66ca3aae3bc0dd2b4c78f2e64b00364da6699d7732596dbeb13053b99b320ed3709d8e6c06994371421714a30ea8ce71ae4894404b4c83ea668
6
+ metadata.gz: 39fb99232136ee69fc5e8b1d180f952cd31b4031e3e8298325c31647212ec8ae21bb27e0ff2d951917fee0eb58c4027306c5ec306f5a3482c9336e3d1fdbedbf
7
+ data.tar.gz: f5565d4016415743ec141be5b8df9fa8b4e171139ee0cb9f0160a27eafea107701c0b0da07179364bbda642798aefd876fef343ec0098e5a2117fbdc82369b23
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.37.0 - October 29, 2026
2
+
3
+ - [Breaking] Call the configured modulus checker's `valid_bank_code?` for US details, as is already done for AU, NZ and CA. US routing numbers the checker does not recognise are now invalid.
4
+
1
5
  ## 1.36.0 - September 29, 2026
2
6
 
3
7
  - Add Slovak translations
data/lib/ibandit/iban.rb CHANGED
@@ -298,7 +298,7 @@ module Ibandit
298
298
  when "AU" then valid_australian_details?
299
299
  when "NZ" then valid_nz_details?
300
300
  when "CA" then valid_ca_details?
301
- when "US" then bank_code_passes_checksum_test?
301
+ when "US" then valid_us_details?
302
302
  else true
303
303
  end
304
304
  end
@@ -392,6 +392,14 @@ module Ibandit
392
392
  valid_modulus_check_branch_code?
393
393
  end
394
394
 
395
+ def valid_us_details?
396
+ return true unless country_code == "US"
397
+ return false unless bank_code_passes_checksum_test?
398
+ return true unless Ibandit.modulus_checker
399
+
400
+ valid_modulus_check_bank_code?
401
+ end
402
+
395
403
  def bank_code_passes_checksum_test?
396
404
  return false unless swift_bank_code
397
405
  return false if swift_bank_code.length != 9
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.36.0"
4
+ VERSION = "1.37.0"
5
5
  end
@@ -1936,6 +1936,82 @@ describe Ibandit::IBAN do
1936
1936
  end
1937
1937
  end
1938
1938
 
1939
+ describe "valid_us_details" do
1940
+ subject { iban.valid_us_details? }
1941
+
1942
+ context "with non-US details" do
1943
+ let(:arg) do
1944
+ {
1945
+ country_code: "GB",
1946
+ bank_code: "1234",
1947
+ branch_code: "200000",
1948
+ account_number: "55779911",
1949
+ }
1950
+ end
1951
+
1952
+ it { is_expected.to be(true) }
1953
+ end
1954
+
1955
+ context "with US details" do
1956
+ let(:arg) do
1957
+ {
1958
+ country_code: "US",
1959
+ bank_code: "026073150",
1960
+ account_number: "2715500356",
1961
+ }
1962
+ end
1963
+
1964
+ context "without a modulus checker defined" do
1965
+ it { is_expected.to be(true) }
1966
+ end
1967
+
1968
+ context "with a modulus checker defined" do
1969
+ before do
1970
+ Ibandit.modulus_checker = double(
1971
+ valid_bank_code?: valid_bank_code,
1972
+ )
1973
+ iban.valid_us_details?
1974
+ end
1975
+
1976
+ after { Ibandit.modulus_checker = nil }
1977
+
1978
+ let(:valid_bank_code) { true }
1979
+
1980
+ it "calls valid_bank_code? with an IBAN object" do
1981
+ expect(Ibandit.modulus_checker).
1982
+ to receive(:valid_bank_code?).
1983
+ with(instance_of(described_class))
1984
+
1985
+ iban.valid_us_details?
1986
+ end
1987
+
1988
+ it { is_expected.to be(true) }
1989
+
1990
+ context "with a bank code that does not exist" do
1991
+ let(:valid_bank_code) { false }
1992
+
1993
+ it { is_expected.to be(false) }
1994
+
1995
+ it "sets the errors on the IBAN" do
1996
+ expect(iban.errors).to include(bank_code: "bank code does not exist")
1997
+ end
1998
+ end
1999
+ end
2000
+
2001
+ context "with a bank code that fails the checksum test" do
2002
+ let(:arg) do
2003
+ {
2004
+ country_code: "US",
2005
+ bank_code: "123456789",
2006
+ account_number: "12345678",
2007
+ }
2008
+ end
2009
+
2010
+ it { is_expected.to be(false) }
2011
+ end
2012
+ end
2013
+ end
2014
+
1939
2015
  describe "Pseudo IBAN #valid?" do
1940
2016
  let(:country_code) { "CA" }
1941
2017
  let(:arg) do
@@ -1988,7 +2064,7 @@ describe Ibandit::IBAN do
1988
2064
  context "US" do
1989
2065
  let(:country_code) { "US" }
1990
2066
 
1991
- specify { expect(iban).to receive(:bank_code_passes_checksum_test?).at_least(1) }
2067
+ specify { expect(iban).to receive(:valid_us_details?).at_least(1) }
1992
2068
  end
1993
2069
  end
1994
2070
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.36.0
4
+ version: 1.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless