ibandit icon indicating copy to clipboard operation
ibandit copied to clipboard

NZ account number wrong length error message

Open tjbarker opened this issue 3 years ago • 0 comments

I've been trying to return error messages to New Zealand bank account users when they provide an incorrect account/suffix number and it seems like the wording in the error message is unhelpful.

for a valid NZ IBAN everything seems fine

iban = Ibandit::IBAN.new('NZ ZZ 12 1234 1234567 123')
iban.valid? => true
iban.account_number => '1234567'
iban.account_number_suffix => '123'

but for an incorrect suffix number

iban = Ibandit::IBAN.new('NZ ZZ 12 1234 1234567 1')
iban.valid? => false
iban.account_number => '1234567'
iban.account_number_suffix => '1'
iban.errors => {:account_number=>"is the wrong length (should be 10 characters)"}

My confusion is that the account number in both cases is 7 digits, but the error is asking for a 10 digit account number.

It seems as though iban.account_number.length should be 10 or the error should be that account number needs to be 7 and suffix needs to be 3 digits.

I don't know if this is an issue and if it is I'm happy be the one who submits a solution, but I'm unsure what the desired functionality would be.

Thanks


versions:

  • ibandit: 1.6.0
  • ruby: 2.7.3
  • rails: 5.2.6

EDIT:

  • updated code block styles

tjbarker avatar Jul 26 '21 11:07 tjbarker