ibandit 1.18.0 → 1.19.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: 2b8d022291e78a27b3f3b8dbfdae181ef51a16e40a0a6c3c0635703ea6a683ad
4
- data.tar.gz: a231a9d66818be2adbf1b3f94dda0ebc5f9c67aea2b61a0c82d6e5f4b6df96a9
3
+ metadata.gz: 47171b99a86687a326f6f674684d5faa489f4aef980e623e2f43d3ffdf841d84
4
+ data.tar.gz: 6074f09b34e39a205fdacabbc1a7376dfec8ac38f2821cbfd1d7ae6a8ba683cf
5
5
  SHA512:
6
- metadata.gz: 1ad4e13578ab1109950350378fb8f065eef1fb022be994a81fd11f5badbefa788a9e38b536fdc2f233f1098bee73bbd3a9854194f76c01bbfaccf5438208e162
7
- data.tar.gz: 031a842efe2feeb64ba57036547df074b55adf23399979b856b457aa97d90b20d6ee4da811de7c5c09e881a61d383132a52c44c59475d7cf468da0652923c20a
6
+ metadata.gz: 9f2ff5eb107524c44c68118315f916d86c7550335bae82747165edbfcf4f11d196b29cd3ec6f130babbf7765866925768dca7b5532357510248e8994e9bca0ae
7
+ data.tar.gz: 0a66dd61f63feeb8534a6b48de006c64928c6f43bf65463ca8e24ccd412d13aa87fc8b8102a4fb54d5585d70a96df91db50be8117c7c025ac576fb0d033c4909
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.19.0 - October 3, 2023
2
+
3
+ - Do not allow all-0 account numbers for CA
4
+
1
5
  ## 1.18.0 - Sept 4, 2023
2
6
 
3
7
  - Remove Ruby 2.6 support
@@ -7,7 +7,7 @@ AU:
7
7
  end: 10
8
8
  excl: false
9
9
  :branch_code_format: "\\d{6}"
10
- :account_number_format: "[A-Z0-9]{5,10}"
10
+ :account_number_format: "(?!0+\\z)[A-Z0-9]{5,10}"
11
11
  :pseudo_iban_bank_code_length: 0
12
12
  :pseudo_iban_branch_code_length: 6
13
13
  :pseudo_iban_account_number_length: 10
@@ -21,7 +21,7 @@ CA:
21
21
  excl: false
22
22
  :bank_code_format: "\\d{4}"
23
23
  :branch_code_format: "\\d{5}"
24
- :account_number_format: "\\d{7,12}"
24
+ :account_number_format: "(?!0+\\z)\\d{7,12}"
25
25
  :national_id_length: 9
26
26
  :pseudo_iban_bank_code_length: 4
27
27
  :pseudo_iban_branch_code_length: 5
data/data/structures.yml CHANGED
@@ -1487,7 +1487,7 @@ AU:
1487
1487
  end: 10
1488
1488
  excl: false
1489
1489
  :branch_code_format: "\\d{6}"
1490
- :account_number_format: "[A-Z0-9]{5,10}"
1490
+ :account_number_format: "(?!0+\\z)[A-Z0-9]{5,10}"
1491
1491
  :pseudo_iban_bank_code_length: 0
1492
1492
  :pseudo_iban_branch_code_length: 6
1493
1493
  :pseudo_iban_account_number_length: 10
@@ -1501,7 +1501,7 @@ CA:
1501
1501
  excl: false
1502
1502
  :bank_code_format: "\\d{4}"
1503
1503
  :branch_code_format: "\\d{5}"
1504
- :account_number_format: "\\d{7,12}"
1504
+ :account_number_format: "(?!0+\\z)\\d{7,12}"
1505
1505
  :national_id_length: 9
1506
1506
  :pseudo_iban_bank_code_length: 4
1507
1507
  :pseudo_iban_branch_code_length: 5
data/lib/ibandit/iban.rb CHANGED
@@ -386,12 +386,6 @@ module Ibandit
386
386
 
387
387
  def valid_australian_details?
388
388
  return true unless country_code == "AU"
389
-
390
- bsb_check? && account_number_not_all_zeros?
391
- end
392
-
393
- def bsb_check?
394
- return true unless country_code == "AU"
395
389
  return true unless Ibandit.modulus_checker
396
390
 
397
391
  valid_modulus_check_branch_code?
@@ -550,12 +544,5 @@ module Ibandit
550
544
 
551
545
  input.slice(2, 2) == Constants::PSEUDO_IBAN_CHECK_DIGITS
552
546
  end
553
-
554
- def account_number_not_all_zeros?
555
- return true if @swift_account_number.to_s.chars.uniq != ["0"]
556
-
557
- @errors[:account_number] = Ibandit.translate(:is_invalid)
558
- false
559
- end
560
547
  end
561
548
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.18.0"
4
+ VERSION = "1.19.0"
5
5
  end
@@ -491,6 +491,17 @@ describe Ibandit::IBAN do
491
491
  its(:valid?) { is_expected.to be false }
492
492
  end
493
493
 
494
+ context "and account number has only zeroes in it" do
495
+ let(:account_number) { "0000000" }
496
+ let(:bank_code) { "0036" }
497
+
498
+ it "is invalid and has the correct errors" do
499
+ expect(subject.valid?).to eq(false)
500
+ expect(subject.errors).
501
+ to eq(account_number: "format is invalid")
502
+ end
503
+ end
504
+
494
505
  context "and a 12 digit account number" do
495
506
  let(:account_number) { "012345678900" }
496
507
  let(:bank_code) { "0036" }
@@ -1662,10 +1673,68 @@ describe Ibandit::IBAN do
1662
1673
  end
1663
1674
  end
1664
1675
 
1665
- describe "#valid?" do
1676
+ describe "Pseudo IBAN #valid?" do
1677
+ let(:country_code) { "CA" }
1678
+ let(:arg) do
1679
+ {
1680
+ country_code: country_code,
1681
+ bank_code: "0036",
1682
+ branch_code: "00063",
1683
+ account_number: "1234567",
1684
+ }
1685
+ end
1686
+
1687
+ describe "validations called" do
1688
+ after { iban.valid? }
1689
+
1690
+ specify { expect(iban).to receive(:valid_pseudo_iban?).at_least(1) }
1691
+ specify { expect(iban).to receive(:valid_pseudo_iban_check_digits?).at_least(1) }
1692
+ specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
1693
+ specify { expect(iban).to receive(:valid_bank_code_length?).at_least(1) }
1694
+ specify { expect(iban).to receive(:valid_branch_code_length?).at_least(1) }
1695
+ specify { expect(iban).to receive(:valid_account_number_length?).at_least(1) }
1696
+ specify { expect(iban).to receive(:valid_bank_code_format?).at_least(1) }
1697
+ specify { expect(iban).to receive(:valid_branch_code_format?).at_least(1) }
1698
+ specify { expect(iban).to receive(:valid_account_number_format?).at_least(1) }
1699
+ specify { expect(iban).to receive(:passes_country_specific_checks?).at_least(1) }
1700
+
1701
+ context "SE" do
1702
+ let(:country_code) { "SE" }
1703
+
1704
+ specify { expect(iban).to receive(:valid_swedish_details?).at_least(1) }
1705
+ end
1706
+
1707
+ context "AU" do
1708
+ let(:country_code) { "AU" }
1709
+
1710
+ specify { expect(iban).to receive(:valid_australian_details?).at_least(1) }
1711
+ end
1712
+
1713
+ context "NZ" do
1714
+ let(:country_code) { "NZ" }
1715
+
1716
+ specify { expect(iban).to receive(:valid_nz_details?).at_least(1) }
1717
+ end
1718
+
1719
+ context "CA" do
1720
+ let(:country_code) { "CA" }
1721
+
1722
+ specify { expect(iban).to receive(:valid_ca_details?).at_least(1) }
1723
+ end
1724
+
1725
+ context "US" do
1726
+ let(:country_code) { "US" }
1727
+
1728
+ specify { expect(iban).to receive(:bank_code_passes_checksum_test?).at_least(1) }
1729
+ end
1730
+ end
1731
+ end
1732
+
1733
+ describe "IBAN #valid?" do
1666
1734
  describe "validations called" do
1667
1735
  after { iban.valid? }
1668
1736
 
1737
+ specify { expect(iban).to receive(:valid_iban?).at_least(1) }
1669
1738
  specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
1670
1739
  specify { expect(iban).to receive(:valid_characters?).at_least(1) }
1671
1740
  specify { expect(iban).to receive(:valid_check_digits?).at_least(1) }
@@ -1697,6 +1766,18 @@ describe Ibandit::IBAN do
1697
1766
  it "runs country specific checks" do
1698
1767
  expect(iban).to receive(:passes_country_specific_checks?).at_least(1)
1699
1768
  end
1769
+
1770
+ context "DE" do
1771
+ let(:arg) do
1772
+ {
1773
+ country_code: "DE",
1774
+ bank_code: "20000000",
1775
+ account_number: "7955791111",
1776
+ }
1777
+ end
1778
+
1779
+ specify { expect(iban).to receive(:supports_iban_determination?).at_least(1) }
1780
+ end
1700
1781
  end
1701
1782
 
1702
1783
  RSpec.shared_examples "a country's IBAN" do |country_code|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.0
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-04 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gc_ruboconfig