Home » Validate » Validate_IE » Manual
This package is in beta state Package contains locale validation for Ireland such as: Bank Account Drivers Licence Numbers IBAN Passport Numbers Phone Numbers Postal Code SSN/PPSN SWIFT Codes See also : The API Documentation The page on http://pear.php.net
Introduction
Introduction – Introduction to validate_IE
Description
The package offers some methods to validate specific data for Ireland
Usage
General usage
Every module of Validate follows the same philosophy. Propose some validation method retuning boolean result. Some methods have some optional parameters to set a stronger check.
sample
<?php
// Include the package
require_once 'Validate/IE.php';
?>
List of available validations
List of available validations – available validation in validate_ie
Validate an Irish PPSN number
The Personal Public Service Number (PPS No) is an identifier issued by Client Identity Services, Department of Social and Family Affairs on behalf of the Minister for Social and Family Affairs in the Republic of Ireland.
sample
<?php
// Include the package
require_once 'Validate/IE.php';
$badSsn = '012345674';
$result = Validate_IE::ssn($badSsn);
echo 'Test ' . $badSsn .' : <br />';
var_export($result);
echo '<br /><br />';
$goodSsn = '1234567W';
$result = Validate_IE::ssn($goodSsn);
echo 'Test ' . $goodSsn .' : <br />';
var_export($result);
?>
Output :
Test 012345674 :
false
Test 1234567W :
true
Validate an Irish postcode
There is no national post code system in Ireland; at present the postalCode method only validates Dublin postal districts: "Dublin 6W", or "D 4" for example.
Validate a phonenumber
Ireland has phone numbers that are built similar to US and Canadian numbers however they have a couple of distinctions.
For instance the STD [Standard Trunk Dial] prefix varies in length: Dublin has the code '01', Cork has '021', Galway 091, and so on.
The phoneNumber method takes two parameters: the first is the phone number to be tested and the second is a flag indicating whether the number should be checked for a valid prefix. This boolean flag defaults to true.
sample with area code prefix testing on by default.
<?php
// Include the package
require_once 'Validate/IE.php';
$phoneNumber = '467875098x';
$result = Validate_IE::phoneNumber($phoneNumber);
echo 'Test ' . $phoneNumber .' : <br />';
var_export($result);
echo '<br />';
$phoneNumber = '014142438';
$result = Validate_IE::phoneNumber($phoneNumber);
echo 'Test ' . $phoneNumber .' : <br />';
var_export($result);
?>
Output :
Test 467875098x :
false
Test 014142438:
true
sample
See now with the requiredAreaCode parameter being utilised.
<?php
// Include the package
require_once 'Validate/IE.php';
$phoneNumber = '87509824';
$result = Validate_IE::phoneNumber($phoneNumber,false);
echo 'Test ' . $phoneNumber .' : <br />';
var_export($result);
echo '<br /><br />';
$phoneNumber = '8750987';
echo 'Test ' . $phoneNumber .' : <br />';
echo 'With $requireAreaCode false <br />';
$result = Validate_IE::phoneNumber($phoneNumber,false);
var_export($result);
echo '<br />';
echo 'With $requireAreaCode true<br />';
$result = Validate_IE::phoneNumber($phoneNumber,true);
var_export($result);
echo '<br /><br />';
$phoneNumber = '(0915)8750987';
echo 'Test ' . $phoneNumber .' : <br />';
echo 'With $requireAreaCode false <br />';
$result = Validate_IE::phoneNumber($phoneNumber,false);
var_export($result);
echo '<br />';
echo 'With $requireAreaCode true<br />';
$result = Validate_IE::phoneNumber($phoneNumber,true);
var_export($result);
?>
Output :
Test 87509824 :
true
Test 8750987 :
With $requireAreaCode false
true
With $requireAreaCode true
false
Test (091)8750987 :
With $requireAreaCode false
false
With $requireAreaCode true
true