Validation

  1. Prerequisite
  2. Synchronous
  3. Asynchronous

1. Prerequisite

To validate an IBAN code you need to know
  • the iban code as string

That's all you need. :-)

2. Synchronous

To validate an IBAN code in synchronous way, you could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private bool IbanValidation(string iban)
        {
            IbanValidator validator = new IbanValidator();

            try
            {
                return validator.ValidateIban(iban);
            }
            catch (AS.IBAN.Helper.IbanException ex)
            {
                //  do some error handling
                return false;
            }
        }
[...]
}

3. Asynchronous

Following the async-await pattern you can also validate an IBAN code in asynchronous way. You could do something like this:

[...]
//    Include IBAN-Api AVENTUM SOLUTIONS GmbH
using AS.IBAN;
using AS.IBAN.Model;
using AS.IBAN.Helper;
[...]
{
[...]
        private async Task<bool> IbanValidationAsync(string iban)
        {
            IbanValidator validator = new IbanValidator();

            try
            {
                return await validator.ValidateIbanAsync(iban);
            }
            catch (AS.IBAN.Helper.IbanException ex)
            {
                //  do some error handling
                return false;
            }
        }
[...]
}




Last edited Nov 22, 2013 at 4:35 PM by AventumSolutions, version 4