diff --git a/config/locales/da.yml b/config/locales/da.yml index fbeb98f..cc251bb 100755 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -18,3 +18,4 @@ da: has_invalid_clearing_code_length: "længden på clearingskoden er ugyldig" has_invalid_serial_number: "ugyldigt serienummer" branch_code_does_not_exist: "filialkode findes ikke" + is_public_iban: "er et offentligt kendt IBAN og kan ikke bruges" diff --git a/config/locales/de.yml b/config/locales/de.yml index e45650e..91219b2 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -18,3 +18,4 @@ de: has_invalid_clearing_code_length: "Länge des Verrechnungscodes ist ungültig" has_invalid_serial_number: "Seriennummer ist ungültig" branch_code_does_not_exist: "Filialcode existiert nicht" + is_public_iban: "ist eine öffentlich bekannte IBAN und kann nicht verwendet werden" diff --git a/config/locales/en.yml b/config/locales/en.yml index 95dc112..7d2584d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -18,3 +18,4 @@ en: has_invalid_clearing_code_length: "clearing code length is invalid" has_invalid_serial_number: "serial number is invalid" branch_code_does_not_exist: "branch code does not exist" + is_public_iban: "is a publicly known IBAN and cannot be used" diff --git a/config/locales/es.yml b/config/locales/es.yml index ef70924..1cacdbb 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -18,3 +18,4 @@ es: has_invalid_clearing_code_length: "codigo de oficina de oficina de compensación invalido" has_invalid_serial_number: "número de serie invalido" branch_code_does_not_exist: "código de sucursal no existe" + is_public_iban: "es un IBAN públicamente conocido y no puede ser utilizado" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 3a80d88..e324395 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -18,3 +18,4 @@ fr: has_invalid_clearing_code_length: "la longueur du clearing code n'est pas valide" has_invalid_serial_number: "le numéro de série n'est pas valide" branch_code_does_not_exist: "le code de la succursale n'existe pas" + is_public_iban: "est un IBAN publiquement connu et ne peut pas être utilisé" diff --git a/config/locales/it.yml b/config/locales/it.yml index a542816..e51cdd8 100755 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -18,3 +18,4 @@ it: has_invalid_clearing_code_length: "lunghezza clearing code non valida" has_invalid_serial_number: "numero di serie non valido" branch_code_does_not_exist: "codice filiale non esiste" + is_public_iban: "è un IBAN pubblicamente noto e non può essere utilizzato" diff --git a/config/locales/nb.yml b/config/locales/nb.yml index 686ee79..50b1f6c 100755 --- a/config/locales/nb.yml +++ b/config/locales/nb.yml @@ -18,3 +18,4 @@ nb: has_invalid_clearing_code_length: "registreringsnummerets lengde er ugyldig" has_invalid_serial_number: "ugyldig serienummer" branch_code_does_not_exist: "filialkode eksisterer ikke" + is_public_iban: "er et offentlig kjent IBAN og kan ikke brukes" diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 8d95d43..1fd47e0 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -18,3 +18,4 @@ nl: has_invalid_clearing_code_length: "lengte clearingcode is ongeldig" has_invalid_serial_number: "serienummer is ongeldig" branch_code_does_not_exist: "takcode bestaat niet" + is_public_iban: "is een publiek bekend IBAN en kan niet worden gebruikt" diff --git a/config/locales/pt.yml b/config/locales/pt.yml index f8c5527..58e4548 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -18,3 +18,4 @@ pt: has_invalid_clearing_code_length: "o comprimento do código de libertação é inválido" has_invalid_serial_number: "o número de série é inválido" branch_code_does_not_exist: "código da filial não existe" + is_public_iban: "é um IBAN publicamente conhecido e não pode ser usado" diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 1390f02..45f3131 100755 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -18,3 +18,4 @@ sl: has_invalid_clearing_code_length: "dolžina klirinške kode ni veljavna" has_invalid_serial_number: "serijska številka ni veljavna" branch_code_does_not_exist: "koda podružnice ne obstaja" + is_public_iban: "je javno znan IBAN in se ne more uporabiti" diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 4866115..fa253c3 100755 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -18,3 +18,4 @@ sv: has_invalid_clearing_code_length: "clearingnumrets längd är ogiltigt" has_invalid_serial_number: "ogiltigt serienummer" branch_code_does_not_exist: "filialkod finns inte" + is_public_iban: "är ett offentligt känt IBAN och kan inte användas" diff --git a/data/french_public_ibans.yml b/data/french_public_ibans.yml new file mode 100644 index 0000000..63a6548 --- /dev/null +++ b/data/french_public_ibans.yml @@ -0,0 +1,90 @@ +--- +french_public_ibans: + - FR7614706001747393731796188 + - FR7612548029989876543210917 + - FR7620041010169876543210921 + - FR7630003035409876543210925 + - FR7630004028379876543210943 + - FR7630003035900005047473407 + - FR7617321122004554326789012 + - FR7615629027170004200280113 + - FR7630004019250001002472678 + - FR7610278060160003088094169 + - FR7610278060150002061390118 + - FR7642559100000800421770862 + - FR7630066109470001000500179 + - FR7630004020370001007151054 + - FR7611315000010800778346685 + - FR7630004007990002571438960 + - FR7630056005020502001051117 + - FR7630004002740001116093658 + - FR7630004024840001056987023 + - FR7630003003340005026601578 + - FR7630076023521354170020066 + - FR7630003012690002603144791 + - FR7630004003350002714557295 + - FR7610278060450002114080165 + - FR7640978000641386267700107 + - FR7613825002000877673388926 + - FR7610071930000000100047658 + - FR7611306000353709186705016 + - FR7620033000010000009372339 + - FR7630004008700001030920949 + - FR7610071910000000202302854 + - FR7630056005020502000363678 + - FR7613906000108504356258065 + - FR7640978000712131280121712 + - FR7640978000712131911849926 + - FR7617806007400419845771541 + - FR7610278394010002248530105 + - FR7619106006364363753470014 + - FR7630003002640002002117020 + - FR7617906000901087838600003 + - FR7610071300000000100828631 + - FR7614707500111119138543942 + - FR7630004008280001329254876 + - FR7612406001243512678670587 + - FR7630004028370001095333394 + - FR7618106008109280508605070 + - FR7631489000100021731414447 + - FR7630056000400040240338029 + - FR7612239000011439530100039 + - FR7617515900000800535876946 + - FR7610071750000000100578588 + - FR7617807006100101907007025 + - FR7610071330000000100023830 + - FR7610278053600001534784518 + - FR7610278053600001534784809 + - FR7610096185050002491042650 + - FR7630003030850003726013607 + - FR7630056009200920000486368 + - FR7630003037660005022008558 + - FR7610807000650222167206217 + - FR7630003041000005011749096 + - FR7630066100110002059130121 + - FR7630004006220001033201356 + - FR7630004003770001011517868 + - FR7630004022490001152204584 + - FR7610278060450002126230191 + - FR7630003036400002002749066 + - FR1420041010050500013M02606 + - FR7630003039540003727104238 + - FR7630003028410015004055947 + - FR7630003040250005036449040 + - FR7630004014320001005727148 + - FR7613106005003002080231255 + - FR7641199110541234567890180 + - FR7642559000011234567890121 + - FR7630007000111234567890144 + - FR7612548029981234567890161 + - FR7614410000011234567890163 + - FR7630076020821234567890186 + - FR7610011000201234567890188 + - FR7611808009101234567890147 + - FR7630056009271234567890182 + - FR7630002032531234567890168 + - FR7611315000011234567890138 + - FR7610107001011234567890129 + - FR7630006000011234567890189 + - FR7630004000031234567890143 + - FR7630001007941234567890185 diff --git a/lib/ibandit/iban.rb b/lib/ibandit/iban.rb index b922747..3e32694 100644 --- a/lib/ibandit/iban.rb +++ b/lib/ibandit/iban.rb @@ -443,6 +443,7 @@ def valid_iban? valid_account_number_format?, valid_local_modulus_check?, passes_country_specific_checks?, + not_a_public_iban?, ].all? end @@ -551,5 +552,20 @@ def pseudo_iban?(input) input.slice(2, 2) == Constants::PSEUDO_IBAN_CHECK_DIGITS end + + def not_a_public_iban? + return true if country_code != "FR" + + @french_public_ibans ||= YAML.load_file( + File.expand_path("../../data/french_public_ibans.yml", __dir__), + )["french_public_ibans"] + + if !@french_public_ibans.include?(iban) + true + else + @errors[:iban] = Ibandit.translate(:is_public_iban) + false + end + end end end diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 1b630ed..1e02343 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -2126,7 +2126,7 @@ end it_behaves_like "a country's IBAN", "FR" do - let(:valid_iban) { "FR14 2004 1010 0505 0001 3M02 606" } + let(:valid_iban) { "FR57 2004 1010 0505 0001 3M02 608" } let(:invalid_iban) { "FRXX14 2004 1010 0505 0001 3M02 606" } end @@ -2529,4 +2529,18 @@ its(:local_check_digits) { is_expected.to eq("0") } end end + + describe "not_a_public_iban?" do + context "with a French IBAN that is not in the public IBANs list" do + let(:iban_code) { "FR1420041010050500013M02607" } + + its(:not_a_public_iban?) { is_expected.to eq(true) } + end + + context "with a French IBAN that is in the public IBANs list" do + let(:iban_code) { "FR7614706001747393731796188" } + + its(:not_a_public_iban?) { is_expected.to eq(false) } + end + end end