function postal_code_validation in Postal Code 7
Custom function defining regexes corresponding to different countries.
5 calls to postal_code_validation()
- postal_code_admin_settings in ./
postal_code.module - Page callback for admin settings form.
- postal_code_field_widget_info in ./
postal_code.module - Implements hook_field_widget_info().
- postal_code_help in ./
postal_code.module - Implements hook_help().
- _postal_code_content_migrate_is_supported_country in ./
content_migrate.zipcode.inc - @file Zipcode content_migrate file
- _postal_code_validator in ./
postal_code.module - Actual validation function.
File
- ./
postal_code.module, line 276
Code
function postal_code_validation() {
$postal_code_validation_data = array(
'us' => array(
'/^\\d{5}(-\\d{4})?$/',
),
'ca' => array(
'/^[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJKLMNPRSTVWXYZ] ?\\d[ABCEGHJKLMNPRSTVWXYZ]\\d$/',
),
'gb' => array(
'/^(GIR|[A-Z]\\d[A-Z\\d]??|[A-Z]{2}\\d[A-Z\\d]??)[ ]??(\\d[A-Z]{2})$/i',
),
'de' => array(
'/^\\b((?:0[1-46-9]\\d{3})|(?:[1-357-9]\\d{4})|(?:[4][0-24-9]\\d{3})|(?:[6][013-9]\\d{3}))\\b$/',
),
'fr' => array(
'/^(F-)?((2[A|B])|[0-9]{2})[0-9]{3}$/',
),
'it' => array(
'/^(V-|I-)?[0-9]{5}$/',
),
'au' => array(
'/^(0[289][0-9]{2})|([1345689][0-9]{3})|(2[0-8][0-9]{2})|(290[0-9])|(291[0-4])|(7[0-4][0-9]{2})|(7[8-9][0-9]{2})$/',
),
'nl' => array(
'/^[1-9][0-9]{3}\\s?([a-zA-Z]{2})?$/',
),
'es' => array(
'/^([1-9]{2}|[0-9][1-9]|[1-9][0-9])[0-9]{3}$/',
),
'dk' => array(
'/^([D-d][K-k])?( |-)?([0-9]{1})?[0-9]{3}$/',
),
'se' => array(
'/^(s-|S-){0,1}[0-9]{3}\\s?[0-9]{2}$/',
),
'be' => array(
'/^[1-9]{1}[0-9]{3}$/',
),
'in' => array(
'/^([1-9][0-9]{2}\\s?[0-9]{3})$/',
),
'pl' => array(
'/^[0-9]{2}-[0-9]{3}$/',
),
);
return $postal_code_validation_data;
}