HumHub Documentation (unofficial)

Iban extends AbstractValidator
in package

Validates IBAN Numbers (International Bank Account Numbers)

Table of Contents

Constants

CHECKFAILED  = 'ibanCheckFailed'
FALSEFORMAT  = 'ibanFalseFormat'
NOTSUPPORTED  = 'ibanNotSupported'
SEPANOTSUPPORTED  = 'ibanSepaNotSupported'

Properties

$messageTemplates  : array<string, string>
$messageVariables  : array<string, mixed>
$options  : array<string, mixed>
$abstractOptions  : AbstractOptions|array<string, mixed>
$allowNonSepa  : bool
Optionally allow IBAN codes from non-SEPA countries. Defaults to true
$countryCode  : string|null
Optional country code by ISO 3166-1
$defaultTranslator  : TranslatorInterface
Default translation object for all validate objects
$defaultTranslatorTextDomain  : string
Default text domain to be used with translator
$ibanRegex  : array<string|int, mixed>
IBAN regexes by country code
$messageLength  : int
Limits the maximum returned length of an error message
$messageTemplates  : array<string, string>
Validation failure message template definitions
$sepaCountries  : array<string|int, string>
The SEPA country codes
$value  : mixed
The value to be validated

Methods

__construct()  : mixed
Sets validator options
__get()  : mixed
Magic function returns the value of the requested property, if and only if it is the value or a message variable.
__invoke()  : bool
Invoke as command
allowNonSepa()  : bool
Returns the optional allow non-sepa countries setting
getCountryCode()  : string|null
Returns the optional country code by ISO 3166-1
getDefaultTranslator()  : TranslatorInterface|null
Get default translation object for all validate objects
getDefaultTranslatorTextDomain()  : string
Get default translation text domain for all validate objects
getMessageLength()  : int
Returns the maximum allowed message length
getMessages()  : array<string, string>
Returns array of validation failure messages
getMessageTemplates()  : array<string, string>
Returns the message templates from the validator
getMessageVariables()  : array<int, string>
Returns an array of the names of variables that are used in constructing validation failure messages
getOption()  : mixed
Returns an option
getOptions()  : array<string, mixed>
Returns all available options
getTranslator()  : TranslatorInterface|null
Return translation object
getTranslatorTextDomain()  : string
Return the translation text domain
hasDefaultTranslator()  : bool
Is there a default translation object set?
hasTranslator()  : bool
Does this validator have its own specific translator?
isTranslatorEnabled()  : bool
Is translation enabled?
isValid()  : bool
Returns true if $value is a valid IBAN
isValueObscured()  : bool
Retrieve flag indicating whether or not value should be obfuscated in messages
setAllowNonSepa()  : $this
Sets the optional allow non-sepa countries setting
setCountryCode()  : $this
Sets an optional country code by ISO 3166-1
setDefaultTranslator()  : void
Set default translation object for all validate objects
setDefaultTranslatorTextDomain()  : void
Set default translation text domain for all validate objects
setMessage()  : $this
Sets the validation failure message template for a particular key
setMessageLength()  : void
Sets the maximum allowed message length
setMessages()  : $this
Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.
setOptions()  : $this
Sets one or multiple options
setTranslator()  : $this
Set translation object
setTranslatorEnabled()  : $this
Indicate whether or not translation should be enabled
setTranslatorTextDomain()  : $this
Set translation text domain
setValueObscured()  : $this
Set flag indicating whether or not value should be obfuscated in messages
createMessage()  : null|string
Constructs and returns a validation failure message with the given message key and value.
error()  : void
getValue()  : mixed
Returns the validation value
setValue()  : void
Sets the value to be validated and clears the messages and errors arrays
translateMessage()  : string
Translate a validation message

Constants

CHECKFAILED

public mixed CHECKFAILED = 'ibanCheckFailed'

FALSEFORMAT

public mixed FALSEFORMAT = 'ibanFalseFormat'

NOTSUPPORTED

public mixed NOTSUPPORTED = 'ibanNotSupported'

SEPANOTSUPPORTED

public mixed SEPANOTSUPPORTED = 'ibanSepaNotSupported'

Properties

$abstractOptions

protected AbstractOptions|array<string, mixed> $abstractOptions = [ 'messages' => [], // Array of validation failure messages 'messageTemplates' => [], // Array of validation failure message templates 'messageVariables' => [], // Array of additional variables available for validation failure messages 'translator' => null, // Translation object to used -> Translator\TranslatorInterface 'translatorTextDomain' => null, // Translation text domain 'translatorEnabled' => true, // Is translation enabled? 'valueObscured' => false, ]

$allowNonSepa

Optionally allow IBAN codes from non-SEPA countries. Defaults to true

protected bool $allowNonSepa = true

$countryCode

Optional country code by ISO 3166-1

protected string|null $countryCode

$defaultTranslatorTextDomain

Default text domain to be used with translator

protected static string $defaultTranslatorTextDomain = 'default'

$ibanRegex

IBAN regexes by country code

protected static array<string|int, mixed> $ibanRegex = ['A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]{4}[0-9]{5}[A-Z0-9]{18}', 'MU' => 'MU[0-9]{2}[A-Z]{4}[0-9]{2}[0-9]{2}[0-9]{12}[0-9]{3}[A-Z]{3}', 'NL' => 'NL[0-9]{2}[A-Z]{4}[0-9]{10}', 'NO' => 'NO[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{1}', 'UA' => 'UA[0-9]{2}[0-9]{6}[0-9]{19}', 'PK' => 'PK[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', 'PL' => 'PL[0-9]{2}[0-9]{8}[0-9]{16}', 'PS' => 'PS[0-9]{2}[A-Z]{4}[A-Z0-9]{21}', 'PT' => 'PT[0-9]{2}[0-9]{4}[0-9]{4}[0-9]{11}[0-9]{2}', 'RO' => 'RO[0-9]{2}[A-Z]{4}[A-Z0-9]{16}', 'RS' => 'RS[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', 'SA' => 'SA[0-9]{2}[0-9]{2}[A-Z0-9]{18}', 'SE' => 'SE[0-9]{2}[0-9]{3}[0-9]{16}[0-9]{1}', 'SI' => 'SI[0-9]{2}[0-9]{5}[0-9]{8}[0-9]{2}', 'SK' => 'SK[0-9]{2}[0-9]{4}[0-9]{6}[0-9]{10}', 'SM' => 'SM[0-9]{2}[A-Z]{1}[0-9]{5}[0-9]{5}[A-Z0-9]{12}', 'TN' => 'TN59[0-9]{2}[0-9]{3}[0-9]{13}[0-9]{2}', 'TR' => 'TR[0-9]{2}[0-9]{5}[A-Z0-9]{1}[A-Z0-9]{16}', 'VG' => 'VG[0-9]{2}[A-Z]{4}[0-9]{16}']

$messageLength

Limits the maximum returned length of an error message

protected static int $messageLength = -1

$messageTemplates

Validation failure message template definitions

protected array<string, string> $messageTemplates = [self::NOTSUPPORTED => 'Unknown country within the IBAN', self::SEPANOTSUPPORTED => 'Countries outside the Single Euro Payments Area (SEPA) are not supported', self::FALSEFORMAT => 'The input has a false IBAN format', self::CHECKFAILED => 'The input has failed the IBAN check']

$sepaCountries

The SEPA country codes

protected static array<string|int, string> $sepaCountries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'FO', 'GL', 'EE', 'FI', 'FR', 'DE', 'GI', 'GR', 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'MC', 'NL', 'NO', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB', 'SM', 'HR']

ISO 3166-1 codes

Methods

__construct()

Sets validator options

public __construct([array<string|int, mixed>|Traversable $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed>|Traversable = []

OPTIONAL

__get()

Magic function returns the value of the requested property, if and only if it is the value or a message variable.

public __get(string $property) : mixed
Parameters
$property : string
Tags
throws
InvalidArgumentException

__invoke()

Invoke as command

public __invoke(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

allowNonSepa()

Returns the optional allow non-sepa countries setting

public allowNonSepa() : bool
Return values
bool

getCountryCode()

Returns the optional country code by ISO 3166-1

public getCountryCode() : string|null
Return values
string|null

getDefaultTranslatorTextDomain()

Get default translation text domain for all validate objects

public static getDefaultTranslatorTextDomain() : string
Return values
string

getMessageLength()

Returns the maximum allowed message length

public static getMessageLength() : int
Return values
int

getMessages()

Returns array of validation failure messages

public getMessages() : array<string, string>
Return values
array<string, string>

getMessageTemplates()

Returns the message templates from the validator

public getMessageTemplates() : array<string, string>
Return values
array<string, string>

getMessageVariables()

Returns an array of the names of variables that are used in constructing validation failure messages

public getMessageVariables() : array<int, string>
Return values
array<int, string>

getOption()

Returns an option

public getOption(string $option) : mixed
Parameters
$option : string

Option to be returned

Tags
throws
InvalidArgumentException
Return values
mixed

Returned option

getOptions()

Returns all available options

public getOptions() : array<string, mixed>
Return values
array<string, mixed>

Array with all available options

getTranslatorTextDomain()

Return the translation text domain

public getTranslatorTextDomain() : string
Return values
string

hasDefaultTranslator()

Is there a default translation object set?

public static hasDefaultTranslator() : bool
Return values
bool

hasTranslator()

Does this validator have its own specific translator?

public hasTranslator() : bool
Return values
bool

isTranslatorEnabled()

Is translation enabled?

public isTranslatorEnabled() : bool
Return values
bool

isValid()

Returns true if $value is a valid IBAN

public isValid(string $value) : bool
Parameters
$value : string
Return values
bool

isValueObscured()

Retrieve flag indicating whether or not value should be obfuscated in messages

public isValueObscured() : bool
Return values
bool

setAllowNonSepa()

Sets the optional allow non-sepa countries setting

public setAllowNonSepa(bool $allowNonSepa) : $this
Parameters
$allowNonSepa : bool
Return values
$this

provides a fluent interface

setCountryCode()

Sets an optional country code by ISO 3166-1

public setCountryCode([string|null $countryCode = null ]) : $this
Parameters
$countryCode : string|null = null
Tags
throws
InvalidArgumentException
Return values
$this

provides a fluent interface

setDefaultTranslatorTextDomain()

Set default translation text domain for all validate objects

public static setDefaultTranslatorTextDomain([string $textDomain = 'default' ]) : void
Parameters
$textDomain : string = 'default'

setMessage()

Sets the validation failure message template for a particular key

public setMessage(string $messageString[, string|null $messageKey = null ]) : $this
Parameters
$messageString : string
$messageKey : string|null = null

OPTIONAL

Tags
throws
InvalidArgumentException
Return values
$this

Provides a fluent interface

setMessageLength()

Sets the maximum allowed message length

public static setMessageLength([int $length = -1 ]) : void
Parameters
$length : int = -1

setMessages()

Sets validation failure message templates given as an array, where the array keys are the message keys, and the array values are the message template strings.

public setMessages(array<string, string> $messages) : $this
Parameters
$messages : array<string, string>
Return values
$this

setOptions()

Sets one or multiple options

public setOptions([array<string, mixed>|Traversable<string, mixed> $options = [] ]) : $this
Parameters
$options : array<string, mixed>|Traversable<string, mixed> = []

Options to set

Tags
throws
InvalidArgumentException

If $options is not an array or Traversable.

Return values
$this

Provides fluid interface

setTranslatorEnabled()

Indicate whether or not translation should be enabled

public setTranslatorEnabled([bool $enabled = true ]) : $this
Parameters
$enabled : bool = true
Return values
$this

setTranslatorTextDomain()

Set translation text domain

public setTranslatorTextDomain([string $textDomain = 'default' ]) : $this
Parameters
$textDomain : string = 'default'
Return values
$this

setValueObscured()

Set flag indicating whether or not value should be obfuscated in messages

public setValueObscured(bool $flag) : $this
Parameters
$flag : bool
Return values
$this

createMessage()

Constructs and returns a validation failure message with the given message key and value.

protected createMessage(string $messageKey, string|array<string|int, mixed>|object $value) : null|string

Returns null if and only if $messageKey does not correspond to an existing template.

If a translator is available and a translation exists for $messageKey, the translation will be used.

Parameters
$messageKey : string
$value : string|array<string|int, mixed>|object
Return values
null|string

error()

protected error(string|null $messageKey[, null|string|array<string|int, mixed>|object $value = null ]) : void
Parameters
$messageKey : string|null
$value : null|string|array<string|int, mixed>|object = null

OPTIONAL

getValue()

Returns the validation value

protected getValue() : mixed
Return values
mixed

Value to be validated

setValue()

Sets the value to be validated and clears the messages and errors arrays

protected setValue(mixed $value) : void
Parameters
$value : mixed

translateMessage()

Translate a validation message

protected translateMessage(string $messageKey, string $message) : string
Parameters
$messageKey : string
$message : string
Return values
string

        
On this page

Search results