# Iban

`Zend_Validate_Iban` validates if a given value could be a IBAN number. IBAN is the abbreviation for "International Bank Account Number".

## Supported options for Zend_Validate_Iban

The following options are supported for `Zend_Validate_Iban`:

- locale: Sets the locale which is used to get the IBAN format for validation.

## IBAN validation

IBAN numbers are always related to a country. This means that different countries use different formats for their IBAN numbers. This is the reason why IBAN numbers always need a locale. By knowing this we already know how to use `Zend_Validate_Iban`.

### Application wide locale

We could use the application wide locale. This means that when no option is given at initiation, `Zend_Validate_Iban` searches for the application wide locale. See the following code snippet:

    // within bootstrap
    Zend_Registry::set('Zend_Locale', new Zend_Locale('de_AT'));

    // within the module
    $validator = new Zend_Validate_Iban();

    if ($validator->isValid('AT611904300234573201')) {
        // IBAN appears to be valid
    } else {
        // IBAN is not valid
    }

#### Application wide locale

Of course this works only when an application wide locale was set within the registry previously. Otherwise `Zend_Locale` will try to use the locale which the client sends or, when non has been send, it uses the environment locale. Be aware that this can lead to unwanted behaviour within the validation.

### Ungreedy IBAN validation

Sometime it is usefull, just to validate if the given value is a IBAN number or not. This means that you don't want to validate it against a defined country. This can be done by using a `FALSE` as locale.

    $validator = new Zend_Validate_Iban(array('locale' => false));
    // Note: you can also set a FALSE as single parameter

    if ($validator->isValid('AT611904300234573201')) {
        // IBAN appears to be valid
    } else {
        // IBAN is not valid
    }

So any IBAN number will be valid. Note that this should not be done when you accept only accounts from a single country.

### Region aware IBAN validation

To validate against a defined country, you just need to give the wished locale. You can do this by the option locale and also afterwards by using `setLocale()`.

    $validator = new Zend_Validate_Iban(array('locale' => 'de_AT'));

    if ($validator->isValid('AT611904300234573201')) {
        // IBAN appears to be valid
    } else {
        // IBAN is not valid
    }

#### Use full qualified locales

You must give a full qualified locale, otherwise the country could not be detected correct because languages are spoken in multiple countries.