Skip to content

Commit

Permalink
Clarify bank code and branch code errors
Browse files Browse the repository at this point in the history
Currently these are returning `modulus_check` based errors when this is
not the case.

This PR updates the errors returned from branch and bank code checks to
be more representative.
  • Loading branch information
JoeSouthan committed Aug 6, 2024
1 parent df14cd8 commit f1a3864
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions config/locales/da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ da:
bank_code_does_not_exist: "bankkoden findes ikke"
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"
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ de:
bank_code_does_not_exist: "Bankleitzahl existiert nicht"
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"
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ en:
bank_code_does_not_exist: "bank code does not exist"
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"
5 changes: 3 additions & 2 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
es:
ibandit:
invalid_country_code: "\"%{country_code}\" no es un código de país IBAN ISO 3166-1 válido"
invalid_check_digits: "Los dígitos de verificación han generado un error en la comprobación del módulo. Se esperaba \"%{expected_check_digits}\", pero se ha recibido \"%{check_digits}\"."
invalid_country_code: '"%{country_code}" no es un código de país IBAN ISO 3166-1 válido'
invalid_check_digits: 'Los dígitos de verificación han generado un error en la comprobación del módulo. Se esperaba "%{expected_check_digits}", pero se ha recibido "%{check_digits}".'
invalid_length: "La longitud no coincide con la especificación SWIFT (se esperaban %{expected_length} caracteres, pero se han recibido %{length})"
is_required: "es obligatorio"
wrong_length: "no tiene la longitud correcta (debe tener %{expected} caracteres)"
Expand All @@ -17,3 +17,4 @@ es:
bank_code_does_not_exist: "codigo bancario inexistente"
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"
1 change: 1 addition & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ fr:
bank_code_does_not_exist: "le code de la banque n'existe pas"
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"
4 changes: 2 additions & 2 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
it:
ibandit:
invalid_country_code: "\"%{country_code}\" non è un codice di paese IBAN 3166-1 valido"
invalid_country_code: '"%{country_code}" non è un codice di paese IBAN 3166-1 valido'
invalid_check_digits: "Controllo del modulo non riuscito per i caratteri. %{expected_check_digits} caratteri previsti, %{check_digits} immessi."
invalid_length: "La lunghezza non corrisponde alla specifica SWIFT (%{expected_length} caratteri previsti, %{length} immessi)"
is_required: "è obbligatorio"
Expand All @@ -17,4 +17,4 @@ it:
bank_code_does_not_exist: "codice banca inesistente"
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"
1 change: 1 addition & 0 deletions config/locales/nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ nb:
bank_code_does_not_exist: "bankkoden eksisterer ikke"
has_invalid_clearing_code_length: "registreringsnummerets lengde er ugyldig"
has_invalid_serial_number: "ugyldig serienummer"
branch_code_does_not_exist: "filialkode eksisterer ikke"
1 change: 1 addition & 0 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ nl:
bank_code_does_not_exist: "bankcode bestaat niet"
has_invalid_clearing_code_length: "lengte clearingcode is ongeldig"
has_invalid_serial_number: "serienummer is ongeldig"
branch_code_does_not_exist: "takcode bestaat niet"
1 change: 1 addition & 0 deletions config/locales/pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ pt:
bank_code_does_not_exist: "o código do banco não existe"
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"
1 change: 1 addition & 0 deletions config/locales/sl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ sl:
bank_code_does_not_exist: "koda banke ne obstaja"
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"
1 change: 1 addition & 0 deletions config/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ sv:
bank_code_does_not_exist: "bankkoden existerar inte"
has_invalid_clearing_code_length: "clearingnumrets längd är ogiltigt"
has_invalid_serial_number: "ogiltigt serienummer"
branch_code_does_not_exist: "filialkod finns inte"
4 changes: 2 additions & 2 deletions lib/ibandit/iban.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,14 @@ def formatted
def valid_modulus_check_bank_code?
return true if Ibandit.modulus_checker.valid_bank_code?(self)

@errors[:bank_code] = Ibandit.translate(:failed_modulus_check)
@errors[:bank_code] = Ibandit.translate(:bank_code_does_not_exist)
false
end

def valid_modulus_check_branch_code?
return true if Ibandit.modulus_checker.valid_branch_code?(self)

@errors[:branch_code] = Ibandit.translate(:failed_modulus_check)
@errors[:branch_code] = Ibandit.translate(:branch_code_does_not_exist)
false
end

Expand Down
10 changes: 5 additions & 5 deletions spec/ibandit/iban_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@
it { is_expected.to be(false) }

it "sets the errors on the IBAN" do
expect(iban.errors).to include(bank_code: "did not pass modulus check")
expect(iban.errors).to include(bank_code: "bank code does not exist")
end
end

Expand All @@ -1368,7 +1368,7 @@
it { is_expected.to be(false) }

it "sets the errors on the IBAN" do
expect(iban.errors).to include(branch_code: "did not pass modulus check")
expect(iban.errors).to include(branch_code: "branch code does not exist")
end
end

Expand Down Expand Up @@ -1581,7 +1581,7 @@
it { is_expected.to be(false) }

it "sets the errors on the IBAN" do
expect(iban.errors).to include(branch_code: "did not pass modulus check")
expect(iban.errors).to include(branch_code: "branch code does not exist")
end
end
end
Expand Down Expand Up @@ -1646,7 +1646,7 @@
it { is_expected.to be(false) }

it "sets the errors on the IBAN" do
expect(iban.errors).to include(branch_code: "did not pass modulus check")
expect(iban.errors).to include(branch_code: "branch code does not exist")
end
end
end
Expand Down Expand Up @@ -1711,7 +1711,7 @@
it { is_expected.to be(false) }

it "sets the errors on the IBAN" do
expect(iban.errors).to include(branch_code: "did not pass modulus check")
expect(iban.errors).to include(branch_code: "branch code does not exist")
end
end
end
Expand Down

0 comments on commit f1a3864

Please sign in to comment.