ibandit 1.18.0 → 1.20.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/data/raw/pseudo_ibans.yml +3 -3
- data/data/structures.yml +3 -3
- data/lib/ibandit/iban.rb +0 -13
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/iban_spec.rb +128 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c3c4654f26735c5412bd2cf3f02c1c5802d1fb2c6c9f775f1472ea0660cc0c3
|
4
|
+
data.tar.gz: d67a80fea5521e0eac1f1486aefaf584b886ebf846a5d05e3bce8ec6fee21182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c092c285a2923177c42b7deb1e305e9a2b4b1625d642da44a1bca3adac3667276216f187e947fe3f90009ec4f1b190898cf12236dac52e202ba8df61e99fe45
|
7
|
+
data.tar.gz: f1fcb038c96b3ba56fe53fe92688b2c19e25a9dfcbdc423d387fbceca835afa4e78337bf87ec3f9dee71d5bd5880837ac4f0728a4f67a45a7a2de0135aa230a7
|
data/CHANGELOG.md
CHANGED
data/data/raw/pseudo_ibans.yml
CHANGED
@@ -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
|
@@ -20,8 +20,8 @@ CA:
|
|
20
20
|
end: 12
|
21
21
|
excl: false
|
22
22
|
:bank_code_format: "\\d{4}"
|
23
|
-
:branch_code_format: "
|
24
|
-
:account_number_format: "\\d{7,12}"
|
23
|
+
:branch_code_format: "0{0,4}[1-9][0-9]{0,4}"
|
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
|
@@ -1500,8 +1500,8 @@ CA:
|
|
1500
1500
|
end: 12
|
1501
1501
|
excl: false
|
1502
1502
|
:bank_code_format: "\\d{4}"
|
1503
|
-
:branch_code_format:
|
1504
|
-
:account_number_format: "\\d{7,12}"
|
1503
|
+
:branch_code_format: 0{0,4}[1-9][0-9]{0,4}
|
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
|
data/lib/ibandit/version.rb
CHANGED
data/spec/ibandit/iban_spec.rb
CHANGED
@@ -422,10 +422,55 @@ describe Ibandit::IBAN do
|
|
422
422
|
{
|
423
423
|
country_code: "CA",
|
424
424
|
bank_code: bank_code,
|
425
|
-
branch_code:
|
425
|
+
branch_code: branch_code,
|
426
426
|
account_number: account_number,
|
427
427
|
}
|
428
428
|
end
|
429
|
+
let(:branch_code) { "00063" }
|
430
|
+
|
431
|
+
context "and a 5 digit branch code" do
|
432
|
+
let(:account_number) { "0123456" }
|
433
|
+
let(:bank_code) { "036" }
|
434
|
+
let(:branch_code) { "00063" }
|
435
|
+
|
436
|
+
its(:country_code) { is_expected.to eq("CA") }
|
437
|
+
its(:bank_code) { is_expected.to eq("0036") }
|
438
|
+
its(:branch_code) { is_expected.to eq("00063") }
|
439
|
+
its(:account_number) { is_expected.to eq("0123456") }
|
440
|
+
its(:swift_bank_code) { is_expected.to eq("0036") }
|
441
|
+
its(:swift_branch_code) { is_expected.to eq("00063") }
|
442
|
+
its(:swift_account_number) { is_expected.to eq("0123456") }
|
443
|
+
its(:swift_national_id) { is_expected.to eq("003600063") }
|
444
|
+
its(:pseudo_iban) { is_expected.to eq("CAZZ003600063_____0123456") }
|
445
|
+
|
446
|
+
its(:iban) { is_expected.to be_nil }
|
447
|
+
its(:valid?) { is_expected.to eq(true) }
|
448
|
+
its(:to_s) { is_expected.to eq("") }
|
449
|
+
end
|
450
|
+
|
451
|
+
context "for an all zero transit number" do
|
452
|
+
let(:account_number) { "0123456" }
|
453
|
+
let(:bank_code) { "036" }
|
454
|
+
let(:branch_code) { "00000" }
|
455
|
+
|
456
|
+
it "is invalid and has the correct errors" do
|
457
|
+
expect(subject.valid?).to eq(false)
|
458
|
+
expect(subject.errors).
|
459
|
+
to eq(branch_code: "format is invalid")
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
context "and a 4 digit branch code" do
|
464
|
+
let(:account_number) { "0123456" }
|
465
|
+
let(:bank_code) { "036" }
|
466
|
+
let(:branch_code) { "0063" }
|
467
|
+
|
468
|
+
it "is invalid and has the correct errors" do
|
469
|
+
expect(subject.valid?).to eq(false)
|
470
|
+
expect(subject.errors).
|
471
|
+
to eq(branch_code: "is the wrong length (should be 5 characters)")
|
472
|
+
end
|
473
|
+
end
|
429
474
|
|
430
475
|
context "and a 3 digit bank code" do
|
431
476
|
let(:account_number) { "0123456" }
|
@@ -491,6 +536,17 @@ describe Ibandit::IBAN do
|
|
491
536
|
its(:valid?) { is_expected.to be false }
|
492
537
|
end
|
493
538
|
|
539
|
+
context "and account number has only zeroes in it" do
|
540
|
+
let(:account_number) { "0000000" }
|
541
|
+
let(:bank_code) { "0036" }
|
542
|
+
|
543
|
+
it "is invalid and has the correct errors" do
|
544
|
+
expect(subject.valid?).to eq(false)
|
545
|
+
expect(subject.errors).
|
546
|
+
to eq(account_number: "format is invalid")
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
494
550
|
context "and a 12 digit account number" do
|
495
551
|
let(:account_number) { "012345678900" }
|
496
552
|
let(:bank_code) { "0036" }
|
@@ -1662,10 +1718,68 @@ describe Ibandit::IBAN do
|
|
1662
1718
|
end
|
1663
1719
|
end
|
1664
1720
|
|
1665
|
-
describe "#valid?" do
|
1721
|
+
describe "Pseudo IBAN #valid?" do
|
1722
|
+
let(:country_code) { "CA" }
|
1723
|
+
let(:arg) do
|
1724
|
+
{
|
1725
|
+
country_code: country_code,
|
1726
|
+
bank_code: "0036",
|
1727
|
+
branch_code: "00063",
|
1728
|
+
account_number: "1234567",
|
1729
|
+
}
|
1730
|
+
end
|
1731
|
+
|
1732
|
+
describe "validations called" do
|
1733
|
+
after { iban.valid? }
|
1734
|
+
|
1735
|
+
specify { expect(iban).to receive(:valid_pseudo_iban?).at_least(1) }
|
1736
|
+
specify { expect(iban).to receive(:valid_pseudo_iban_check_digits?).at_least(1) }
|
1737
|
+
specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
|
1738
|
+
specify { expect(iban).to receive(:valid_bank_code_length?).at_least(1) }
|
1739
|
+
specify { expect(iban).to receive(:valid_branch_code_length?).at_least(1) }
|
1740
|
+
specify { expect(iban).to receive(:valid_account_number_length?).at_least(1) }
|
1741
|
+
specify { expect(iban).to receive(:valid_bank_code_format?).at_least(1) }
|
1742
|
+
specify { expect(iban).to receive(:valid_branch_code_format?).at_least(1) }
|
1743
|
+
specify { expect(iban).to receive(:valid_account_number_format?).at_least(1) }
|
1744
|
+
specify { expect(iban).to receive(:passes_country_specific_checks?).at_least(1) }
|
1745
|
+
|
1746
|
+
context "SE" do
|
1747
|
+
let(:country_code) { "SE" }
|
1748
|
+
|
1749
|
+
specify { expect(iban).to receive(:valid_swedish_details?).at_least(1) }
|
1750
|
+
end
|
1751
|
+
|
1752
|
+
context "AU" do
|
1753
|
+
let(:country_code) { "AU" }
|
1754
|
+
|
1755
|
+
specify { expect(iban).to receive(:valid_australian_details?).at_least(1) }
|
1756
|
+
end
|
1757
|
+
|
1758
|
+
context "NZ" do
|
1759
|
+
let(:country_code) { "NZ" }
|
1760
|
+
|
1761
|
+
specify { expect(iban).to receive(:valid_nz_details?).at_least(1) }
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
context "CA" do
|
1765
|
+
let(:country_code) { "CA" }
|
1766
|
+
|
1767
|
+
specify { expect(iban).to receive(:valid_ca_details?).at_least(1) }
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
context "US" do
|
1771
|
+
let(:country_code) { "US" }
|
1772
|
+
|
1773
|
+
specify { expect(iban).to receive(:bank_code_passes_checksum_test?).at_least(1) }
|
1774
|
+
end
|
1775
|
+
end
|
1776
|
+
end
|
1777
|
+
|
1778
|
+
describe "IBAN #valid?" do
|
1666
1779
|
describe "validations called" do
|
1667
1780
|
after { iban.valid? }
|
1668
1781
|
|
1782
|
+
specify { expect(iban).to receive(:valid_iban?).at_least(1) }
|
1669
1783
|
specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
|
1670
1784
|
specify { expect(iban).to receive(:valid_characters?).at_least(1) }
|
1671
1785
|
specify { expect(iban).to receive(:valid_check_digits?).at_least(1) }
|
@@ -1697,6 +1811,18 @@ describe Ibandit::IBAN do
|
|
1697
1811
|
it "runs country specific checks" do
|
1698
1812
|
expect(iban).to receive(:passes_country_specific_checks?).at_least(1)
|
1699
1813
|
end
|
1814
|
+
|
1815
|
+
context "DE" do
|
1816
|
+
let(:arg) do
|
1817
|
+
{
|
1818
|
+
country_code: "DE",
|
1819
|
+
bank_code: "20000000",
|
1820
|
+
account_number: "7955791111",
|
1821
|
+
}
|
1822
|
+
end
|
1823
|
+
|
1824
|
+
specify { expect(iban).to receive(:supports_iban_determination?).at_least(1) }
|
1825
|
+
end
|
1700
1826
|
end
|
1701
1827
|
|
1702
1828
|
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.
|
4
|
+
version: 1.20.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-
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gc_ruboconfig
|