package Default
inherited_from \Zend\Validator\AbstractValidator

 Methods

Constructor for the PostCode validator

__construct(array|\Traversable $options = array()

Accepts a string locale and/or "format".

inherited_from \Zend\Validator\AbstractValidator::__construct()

Parameters

$options

array\Traversable

Exceptions

\Zend\Validator\Exception\ExtensionNotLoadedException if ext/intl is not present

Abstract constructor for all validators A validator should accept following parameters: - nothing f.e. Validator() - one or multiple scalar values f.e. Validator($first, $second, $third) - an array f.e. Validator(array($first => 'first', $second => 'second', $third => 'third')) - an instance of Traversable f.e. Validator($config_instance)

__construct(array|\Traversable $options = null
Inherited

Parameters

$options

array\Traversable

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

__get(string $property) : mixed
Inherited

Parameters

$property

string

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixed

Invoke as command

__invoke(mixed $value) : boolean
Inherited

Parameters

$value

mixed

Returns

boolean

Get default translation object for all validate objects

getDefaultTranslator() : \Zend\Validator\Translator\TranslatorInterface | null
InheritedStatic

Returns

\Zend\Validator\Translator\TranslatorInterfacenull

Get default translation text domain for all validate objects

getDefaultTranslatorTextDomain() : string
InheritedStatic

Returns

string

Returns the set postal code format

getFormat() : string | null

Returns

stringnull

Returns the set locale

getLocale() : string | null

Returns

stringnullThe set locale

Returns the maximum allowed message length

getMessageLength() : integer
InheritedStatic

Returns

integer

Returns the message templates from the validator

getMessageTemplates() : array
Inherited

Returns

array

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

getMessageVariables() : array
Inherited

Returns

array

Returns array of validation failure messages

getMessages() : array
Inherited

If isValid() was never called or if the most recent isValid() call returned true, then this method returns an empty array.

inherited_from \Zend\Validator\ValidatorInterface::getMessages()

Returns

array

Returns an option

getOption(string $option) : mixed
Inherited

Parameters

$option

string

Option to be returned

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

mixedReturned option

Returns all available options

getOptions() : array
Inherited

Returns

arrayArray with all available options

Returns the actual set service

getService() : mixed | null

Returns

mixednull

Return translation object

getTranslator() : \Zend\Validator\Translator\TranslatorInterface | null
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::getTranslator()

Returns

\Zend\Validator\Translator\TranslatorInterfacenull

Return the translation text domain

getTranslatorTextDomain() : string
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::getTranslatorTextDomain()

Returns

string

Is there a default translation object set?

hasDefaultTranslator() : boolean
InheritedStatic

Returns

boolean

Does this validator have its own specific translator?

hasTranslator() : boolean
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::hasTranslator()

Returns

boolean

Is translation enabled?

isTranslatorEnabled() : boolean
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::isTranslatorEnabled()

Returns

boolean

Returns true if and only if $value is a valid postalcode

isValid(string $value) : boolean

Parameters

$value

string

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

boolean

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

isValueObscured() : boolean
Inherited

Returns

boolean

Set default translation object for all validate objects

setDefaultTranslator(\Zend\Validator\Translator\TranslatorInterface|null $translator = null, string $textDomain = null) : void
InheritedStatic

Parameters

$translator

\Zend\Validator\Translator\TranslatorInterfacenull

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Set default translation text domain for all validate objects

setDefaultTranslatorTextDomain(string $textDomain = 'default') : void
InheritedStatic

Parameters

$textDomain

string

Sets a self defined postal format as regex

setFormat(string $format) : \Zend\I18n\Validator\PostCode

Parameters

$format

string

Returns

\Zend\I18n\Validator\PostCodeProvides fluid interface

Sets the locale to use

setLocale(string|null $locale) : \Zend\I18n\Validator\PostCode

Parameters

$locale

stringnull

Returns

\Zend\I18n\Validator\PostCodeProvides fluid interface

Sets the validation failure message template for a particular key

setMessage(string $messageString, string $messageKey = null) : \Zend\Validator\AbstractValidator
Inherited

Parameters

$messageString

string

$messageKey

string

OPTIONAL

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

\Zend\Validator\AbstractValidatorProvides a fluent interface

Sets the maximum allowed message length

setMessageLength(integer $length = -1
InheritedStatic

Parameters

$length

integer

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.

setMessages(array $messages) : \Zend\Validator\AbstractValidator
Inherited

Parameters

$messages

array

Returns

\Zend\Validator\AbstractValidator

Sets one or multiple options

setOptions(array|\Traversable $options = array()) : \Zend\Validator\AbstractValidator
Inherited

Parameters

$options

array\Traversable

Options to set

Exceptions

\Zend\Validator\Exception\InvalidArgumentException If $options is not an array or Traversable

Returns

\Zend\Validator\AbstractValidatorProvides fluid interface

Sets a new callback for service validation

setService(mixed $service) : \Zend\I18n\Validator\PostCode

Parameters

$service

mixed

Returns

\Zend\I18n\Validator\PostCodeProvides fluid interface

Set translation object

setTranslator(\Zend\Validator\Translator\TranslatorInterface|null $translator = null, string $textDomain = null) : \Zend\Validator\AbstractValidator
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::setTranslator()

Parameters

$translator

\Zend\Validator\Translator\TranslatorInterfacenull

$textDomain

string

(optional)

Exceptions

\Zend\Validator\Exception\InvalidArgumentException

Returns

\Zend\Validator\AbstractValidator

Indicate whether or not translation should be enabled

setTranslatorEnabled(boolean $flag = true) : \Zend\Validator\AbstractValidator
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::setTranslatorEnabled()

Parameters

$flag

boolean

Returns

\Zend\Validator\AbstractValidator

Set translation text domain

setTranslatorTextDomain(string $textDomain = 'default') : \Zend\Validator\AbstractValidator
Inherited
inherited_from \Zend\Validator\Translator\TranslatorAwareInterface::setTranslatorTextDomain()

Parameters

$textDomain

string

Returns

\Zend\Validator\AbstractValidator

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

setValueObscured(boolean $flag) : \Zend\Validator\AbstractValidator
Inherited

Parameters

$flag

boolean

Returns

\Zend\Validator\AbstractValidator

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

createMessage(string $messageKey, string|array|object $value) : string
Inherited

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

stringarrayobject

Returns

string

error()

error(string $messageKey, string $value = null) : void
Inherited

Parameters

$messageKey

string

$value

string

OPTIONAL

Returns the validation value

getValue() : mixed
Inherited

Returns

mixedValue to be validated

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

setValue(mixed $value) : void
Inherited

Parameters

$value

mixed

Translate a validation message

translateMessage(string $messageKey, string $message) : string
Inherited

Parameters

$messageKey

string

$message

string

Returns

string

 Properties

 

$abstractOptions

$abstractOptions 

Default

array('messages' => array(), 'messageTemplates' => array(), 'messageVariables' => array(), 'translator' => null, 'translatorTextDomain' => null, 'translatorEnabled' => true, 'valueObscured' => false)
 

Default translation object for all validate objects

$defaultTranslator : \Zend\Validator\Translator\TranslatorInterface

Default

Static
 

Default text domain to be used with translator

$defaultTranslatorTextDomain : string

Default

'default'
Static
 

Optional Manual postal code format

$format : string | null

Default

 

Optional Locale to use

$locale : string | null

Default

 

Limits the maximum returned length of an error message

$messageLength : integer

Default

-1
Static
 

$messageTemplates

$messageTemplates : array

Default

array(self::INVALID => "Invalid type given. String or integer expected", self::NO_MATCH => "The input does not appear to be a postal code", self::SERVICE => "The input does not appear to be a postal code", self::SERVICEFAILURE => "An exception has been raised while validating the input")
 

Postal Code regexes by territory

$postCodeRegex : array

Default

array('GB' => 'GIR[ ]?0AA|^((AB|AL|B|BA|BB|BD|BH|BL|BN|BR|BS|BT|CA|CB|CF|CH|CM|CO|CR|CT|CV|CW|DA|DD|DE|DG|DH|DL|DN|DT|DY|E|EC|EH|EN|EX|FK|FY|G|GL|GY|GU|HA|HD|HG|HP|HR|HS|HU|HX|IG|IM|IP|IV|JE|KA|KT|KW|KY|L|LA|LD|LE|LL|LN|LS|LU|M|ME|MK|ML|N|NE|NG|NN|NP|NR|NW|OL|OX|PA|PE|PH|PL|PO|PR|RG|RH|RM|S|SA|SE|SG|SK|SL|SM|SN|SO|SP|SR|SS|ST|SW|SY|TA|TD|TF|TN|TQ|TR|TS|TW|UB|W|WA|WC|WD|WF|WN|WR|WS|WV|YO|ZE)(\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}))$|^BFPO[ ]?\d{1,4}', 'JE' => 'JE\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', 'GG' => 'GY\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', 'IM' => 'IM\d[\dA-Z]?[ ]?\d[ABD-HJLN-UW-Z]{2}', 'US' => '\d{5}([ \-]\d{4})?', 'CA' => '[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][ ]?\d[ABCEGHJ-NPRSTV-Z]\d', 'DE' => '\d{5}', 'JP' => '\d{3}-\d{4}', 'FR' => '(?!(0{2})|(9(6|9))[ ]?\d{3})(\d{2}[ ]?\d{3})', 'AU' => '\d{4}', 'IT' => '\d{5}', 'CH' => '\d{4}', 'AT' => '\d{4}', 'ES' => '\d{5}', 'NL' => '\d{4}[ ]?[A-Z]{2}', 'BE' => '\d{4}', 'DK' => '\d{4}', 'SE' => '\d{3}[ ]?\d{2}', 'NO' => '(?!0000)\d{4}', 'BR' => '\d{5}[\-]?\d{3}', 'PT' => '\d{4}([\-]\d{3})?', 'FI' => '\d{5}', 'AX' => '22\d{3}', 'KR' => '\d{3}[\-]\d{3}', 'CN' => '\d{6}', 'TW' => '\d{3}(\d{2})?', 'SG' => '\d{6}', 'DZ' => '\d{5}', 'AD' => 'AD\d{3}', 'AR' => '([A-HJ-NP-Z])?\d{4}([A-Z]{3})?', 'AM' => '(37)?\d{4}', 'AZ' => '\d{4}', 'BH' => '((1[0-2]|[2-9])\d{2})?', 'BD' => '\d{4}', 'BB' => '(BB\d{5})?', 'BY' => '\d{6}', 'BM' => '[A-Z]{2}[ ]?[A-Z0-9]{2}', 'BA' => '\d{5}', 'IO' => 'BBND 1ZZ', 'BN' => '[A-Z]{2}[ ]?\d{4}', 'BG' => '\d{4}', 'KH' => '\d{5}', 'CV' => '\d{4}', 'CL' => '\d{7}', 'CR' => '\d{4,5}|\d{3}-\d{4}', 'HR' => '\d{5}', 'CY' => '\d{4}', 'CZ' => '\d{3}[ ]?\d{2}', 'DO' => '\d{5}', 'EC' => '([A-Z]\d{4}[A-Z]|(?:[A-Z]{2})?\d{6})?', 'EG' => '\d{5}', 'EE' => '\d{5}', 'FO' => '\d{3}', 'GE' => '\d{4}', 'GR' => '\d{3}[ ]?\d{2}', 'GL' => '39\d{2}', 'GT' => '\d{5}', 'HT' => '\d{4}', 'HN' => '(?:\d{5})?', 'HU' => '\d{4}', 'IS' => '\d{3}', 'IN' => '\d{6}', 'ID' => '\d{5}', 'IE' => '((D|DUBLIN)?([1-9]|6[wW]|1[0-8]|2[024]))?', 'IL' => '\d{5}', 'JO' => '\d{5}', 'KZ' => '\d{6}', 'KE' => '\d{5}', 'KW' => '\d{5}', 'LA' => '\d{5}', 'LV' => '\d{4}', 'LB' => '(\d{4}([ ]?\d{4})?)?', 'LI' => '(948[5-9])|(949[0-7])', 'LT' => '\d{5}', 'LU' => '\d{4}', 'MK' => '\d{4}', 'MY' => '\d{5}', 'MV' => '\d{5}', 'MT' => '[A-Z]{3}[ ]?\d{2,4}', 'MU' => '(\d{3}[A-Z]{2}\d{3})?', 'MX' => '\d{5}', 'MD' => '\d{4}', 'MC' => '980\d{2}', 'MA' => '\d{5}', 'NP' => '\d{5}', 'NZ' => '\d{4}', 'NI' => '((\d{4}-)?\d{3}-\d{3}(-\d{1})?)?', 'NG' => '(\d{6})?', 'OM' => '(PC )?\d{3}', 'PK' => '\d{5}', 'PY' => '\d{4}', 'PH' => '\d{4}', 'PL' => '\d{2}-\d{3}', 'PR' => '00[679]\d{2}([ \-]\d{4})?', 'RO' => '\d{6}', 'RU' => '\d{6}', 'SM' => '4789\d', 'SA' => '\d{5}', 'SN' => '\d{5}', 'SK' => '\d{3}[ ]?\d{2}', 'SI' => '\d{4}', 'ZA' => '\d{4}', 'LK' => '\d{5}', 'TJ' => '\d{6}', 'TH' => '\d{5}', 'TN' => '\d{4}', 'TR' => '\d{5}', 'TM' => '\d{6}', 'UA' => '\d{5}', 'UY' => '\d{5}', 'UZ' => '\d{6}', 'VA' => '00120', 'VE' => '\d{4}', 'ZM' => '\d{5}', 'AS' => '96799', 'CC' => '6799', 'CK' => '\d{4}', 'RS' => '\d{6}', 'ME' => '8\d{4}', 'CS' => '\d{5}', 'YU' => '\d{5}', 'CX' => '6798', 'ET' => '\d{4}', 'FK' => 'FIQQ 1ZZ', 'NF' => '2899', 'FM' => '(9694[1-4])([ \-]\d{4})?', 'GF' => '9[78]3\d{2}', 'GN' => '\d{3}', 'GP' => '9[78][01]\d{2}', 'GS' => 'SIQQ 1ZZ', 'GU' => '969[123]\d([ \-]\d{4})?', 'GW' => '\d{4}', 'HM' => '\d{4}', 'IQ' => '\d{5}', 'KG' => '\d{6}', 'LR' => '\d{4}', 'LS' => '\d{3}', 'MG' => '\d{3}', 'MH' => '969[67]\d([ \-]\d{4})?', 'MN' => '\d{6}', 'MP' => '9695[012]([ \-]\d{4})?', 'MQ' => '9[78]2\d{2}', 'NC' => '988\d{2}', 'NE' => '\d{4}', 'VI' => '008(([0-4]\d)|(5[01]))([ \-]\d{4})?', 'PF' => '987\d{2}', 'PG' => '\d{3}', 'PM' => '9[78]5\d{2}', 'PN' => 'PCRN 1ZZ', 'PW' => '96940', 'RE' => '9[78]4\d{2}', 'SH' => '(ASCN|STHL) 1ZZ', 'SJ' => '\d{4}', 'SO' => '\d{5}', 'SZ' => '[HLMS]\d{3}', 'TC' => 'TKCA 1ZZ', 'WF' => '986\d{2}', 'YT' => '976\d{2}')
Static
 

Optional Service callback for additional validation

$service : mixed | null

Default

 

The value to be validated

$value : mixed

Default

 Constants

 

INVALID

INVALID = 'postcodeInvalid' 
 

NO_MATCH

NO_MATCH = 'postcodeNoMatch' 
 

SERVICE

SERVICE = 'postcodeService' 
 

SERVICEFAILURE

SERVICEFAILURE = 'postcodeServiceFailure'