IBAN Validation

15 posts / 0 new
Last post
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57
IBAN Validation

This function will return a 1 if the IBAN adheres to the validation else it will return 0 if it is false.

The International Bank Account Number (IBAN) is an internationally agreed means of identifying bank accounts across national borders with a reduced risk of propagating transcription errors.

An IBAN is validated by converting it into an integer and performing a basic mod-97 operation (as described in ISO 7064) on it. If the IBAN is valid, the remainder equals 1.

I have tested this against the examples listed on the source page but it has not been extensively tested.  So if anyone uses this and finds problems, or can validate that it works properly I would appreciate a comment.

Source: http://en.wikipedia.org/wiki/International_Bank_Account_Number

March 17, 2015 - Updated the custom function so it can now handle IBANs that are longer than 30 characters.

wmollink
Offline
Joined: 03/12/2015 - 14:49

Hello Brian
I tested the function on a large batch of IBAN-numbers. I got 6 (out of about 30.000) that gave validation 0. I checked these online and they checked out all right.
So I looked at your code and changed it, so the function gave the length of the number after converting it to numbers and removing the spaces. It turned out that the 6 had a length of more then 30. The longest were 37 long (countrycode MT). So I added a fifth round and then all the numbers checked out all right.
I am using Idea 8.5 and looked in the language browser for the mod-function, but could not find it. Yet the function worked all right. Is this an error in the language browser? If so do you know of any more of these mistakes?
Greetings
Wim

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Wim,

Thanks for the information, I guess I had assumed 30 would be the max.  I will look at the code and maybe add a loop depending on the length of number to validate.  That would hopefully handle items that might be even longer than your 37 characters.

Actually the Mod is a visual basic key word and not an IDEAScripting key word.  There are quite a few visual basic commands that work in IDEAScript that are not documented in the language browser.  I have listed some of them in the VB language section of the site but I haven't had a chance to go through all of them.  The only way to know if they work is to test them out and unfortunately sometimes they work as planned and other times they don't, it has been a bit of a hit and miss sometimes.

Thanks

Brian

MagiBzh
Offline
Joined: 07/10/2015 - 04:15

Hi Brian,
Hope evrything is well with you. I tried to use your function but I got an error message saying "syntax error". could you please advise on what to do to make this function works ?
Many thanks for considering my request.
Magi

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Magi, what version of IDEA are you using?

MagiBzh
Offline
Joined: 07/10/2015 - 04:15

Hi Brian,
IDEA version 9.2.0.630 (X86 Unicode) :)

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

ok, I will check it out.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Magi,

I just tried it on 9.2 with no problems.  Are you using it on a character field?  The only other difference is that you are using unicode and mine is ASCII, unfortunately I don't have a unicode version to test it out on.

Brian

MagiBzh
Offline
Joined: 07/10/2015 - 04:15

Hi Brian,
Yes it is a character field.
Magi

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Magi,

Then I am not sure what the problem might be as I can get it to work.  The only thing I can think of is some preblem between the ASCII and Unicode versions of IDEA.  Any chance you can get a screen capture of the error message.

Thanks

Brian

MagiBzh
Offline
Joined: 07/10/2015 - 04:15

Hi Brian,
I upload a screenshot. the character field "BANK_ACCOUNT_NUM" has 31 length, do you think it could be the problem ?
Br,
Magi

Images: 

Pages