Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

File: /modules/zend.validator.iban.html

Size:12979
Storage flags:no_autoload,compress/gzip (27%)

Iban Validator — Zend Framework 2 2.4.2 documentation

Iban Validator

Zend\Validator\Iban validates if a given value could be a IBAN number. IBAN is the abbreviation for “International Bank Account Number”.

Supported options for Zend\Validator\Iban

The following options are supported for Zend\Validator\Iban:

  • country_code: Sets the country code 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 country code. By knowing this we already know how to use Zend\Validator\Iban.

Ungreedy IBAN validation

Sometime it is useful, 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.

1
2
3
4
5
6
7
8
$validator = new Zend\Validator\Iban(array('country_code' => 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 country code. You can do this by the option country_code and also afterwards by using setCountryCode().

1
2
3
4
5
6
7
$validator = new Zend\Validator\Iban(array('country_code' => 'AT'));

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

Table Of Contents

Previous topic

Hostname Validator

Next topic

Identical Validator

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Iban Validator on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.

For more information about the PHK package format: http://phk.tekwire.net